pub trait Fs: Send + Sync {
// Required methods
fn read(&self, p: &Path) -> Result<Vec<u8>, Error>;
fn write(&self, p: &Path, b: &[u8]) -> Result<(), Error>;
fn append(&self, p: &Path, b: &[u8]) -> Result<(), Error>;
fn is_file(&self, p: &Path) -> bool;
fn is_dir(&self, p: &Path) -> bool;
fn read_dir(&self, p: &Path) -> Result<Vec<PathBuf>, Error>;
fn create_dir_all(&self, p: &Path) -> Result<(), Error>;
fn remove_file(&self, p: &Path) -> Result<(), Error>;
fn rename(&self, a: &Path, b: &Path) -> Result<(), Error>;
fn stamp(&self, p: &Path) -> Result<(Option<SystemTime>, u64), Error>;
fn canonicalize(&self, p: &Path) -> Result<PathBuf, Error>;
// Provided method
fn write_atomic(&self, p: &Path, b: &[u8]) -> Result<(), Error> { ... }
}Expand description
ファイルの読み書きの口(with で計算ごとに渡す)。パスはネイティブと同じ形で受ける
Required Methods§
fn read(&self, p: &Path) -> Result<Vec<u8>, Error>
fn append(&self, p: &Path, b: &[u8]) -> Result<(), Error>
fn is_file(&self, p: &Path) -> bool
fn is_dir(&self, p: &Path) -> bool
fn create_dir_all(&self, p: &Path) -> Result<(), Error>
fn remove_file(&self, p: &Path) -> Result<(), Error>
fn rename(&self, a: &Path, b: &Path) -> Result<(), Error>
fn canonicalize(&self, p: &Path) -> Result<PathBuf, Error>
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".