Skip to main content

Fs

Trait Fs 

Source
pub trait Fs: Send + Sync {
    // Required methods
    fn read(&self, p: &Path) -> Result<Vec<u8>>;
    fn write(&self, p: &Path, b: &[u8]) -> Result<()>;
    fn append(&self, p: &Path, b: &[u8]) -> Result<()>;
    fn is_file(&self, p: &Path) -> bool;
    fn is_dir(&self, p: &Path) -> bool;
    fn read_dir(&self, p: &Path) -> Result<Vec<PathBuf>>;
    fn create_dir_all(&self, p: &Path) -> Result<()>;
    fn remove_file(&self, p: &Path) -> Result<()>;
    fn rename(&self, a: &Path, b: &Path) -> Result<()>;
    fn stamp(&self, p: &Path) -> Result<Stamp>;
    fn canonicalize(&self, p: &Path) -> Result<PathBuf>;

    // Provided method
    fn write_atomic(&self, p: &Path, b: &[u8]) -> Result<()> { ... }
}
Expand description

ファイルの読み書きの口(with で計算ごとに渡す)。パスはネイティブと同じ形で受ける

Required Methods§

Source

fn read(&self, p: &Path) -> Result<Vec<u8>>

Source

fn write(&self, p: &Path, b: &[u8]) -> Result<()>

書く(あれば置き換える)

Source

fn append(&self, p: &Path, b: &[u8]) -> Result<()>

Source

fn is_file(&self, p: &Path) -> bool

Source

fn is_dir(&self, p: &Path) -> bool

Source

fn read_dir(&self, p: &Path) -> Result<Vec<PathBuf>>

フォルダの中のファイル・フォルダのパス(並びは決まっていない)

Source

fn create_dir_all(&self, p: &Path) -> Result<()>

Source

fn remove_file(&self, p: &Path) -> Result<()>

Source

fn rename(&self, a: &Path, b: &Path) -> Result<()>

Source

fn stamp(&self, p: &Path) -> Result<Stamp>

更新の印(読み直しの判定用)

Source

fn canonicalize(&self, p: &Path) -> Result<PathBuf>

Provided Methods§

Source

fn write_atomic(&self, p: &Path, b: &[u8]) -> Result<()>

書く(途中で落ちても前か新しい中身のどちらかが残る)。既定は Fs::write

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Fs for MemFs

Source§

impl Fs for StdFs

Available on non-WebAssembly only.