pub trait FileSystem: Send + Sync {
type File: File;
Show 13 methods
// Required methods
fn open_file(
&self,
path: impl AsRef<Utf8Path>,
flags: OpenFlags,
) -> Result<Self::File>;
fn metadata(&self, path: impl AsRef<Utf8Path>) -> Result<Metadata>;
fn rename(
&self,
from: impl AsRef<Utf8Path>,
to: impl AsRef<Utf8Path>,
) -> Result<()>;
fn exists(&self, path: impl AsRef<Utf8Path>) -> Result<bool>;
fn create_dir(&self, path: impl AsRef<Utf8Path>) -> Result<()>;
fn remove_dir(&self, path: impl AsRef<Utf8Path>) -> Result<()>;
fn remove_file(&self, path: impl AsRef<Utf8Path>) -> Result<()>;
fn read_dir(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<DirEntry>>;
// Provided methods
fn create_file(&self, path: impl AsRef<Utf8Path>) -> Result<Self::File> { ... }
fn remove(&self, path: impl AsRef<Utf8Path>) -> Result<()> { ... }
fn read(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<u8>> { ... }
fn read_to_string(&self, path: impl AsRef<Utf8Path>) -> Result<String> { ... }
fn write(
&self,
path: impl AsRef<Utf8Path>,
data: impl AsRef<[u8]>,
) -> Result<()> { ... }
}Required Associated Types§
Required Methods§
fn open_file( &self, path: impl AsRef<Utf8Path>, flags: OpenFlags, ) -> Result<Self::File>
fn metadata(&self, path: impl AsRef<Utf8Path>) -> Result<Metadata>
fn rename( &self, from: impl AsRef<Utf8Path>, to: impl AsRef<Utf8Path>, ) -> Result<()>
fn exists(&self, path: impl AsRef<Utf8Path>) -> Result<bool>
fn create_dir(&self, path: impl AsRef<Utf8Path>) -> Result<()>
fn remove_dir(&self, path: impl AsRef<Utf8Path>) -> Result<()>
fn remove_file(&self, path: impl AsRef<Utf8Path>) -> Result<()>
fn read_dir(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<DirEntry>>
Provided Methods§
fn create_file(&self, path: impl AsRef<Utf8Path>) -> Result<Self::File>
fn remove(&self, path: impl AsRef<Utf8Path>) -> Result<()>
Sourcefn read(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<u8>>
fn read(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<u8>>
Corresponds to std::fs::read().
Will open a file at the path and read the entire file into a buffer.
fn read_to_string(&self, path: impl AsRef<Utf8Path>) -> Result<String>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.