Trait diskplan_filesystem::Filesystem
source · pub trait Filesystem {
Show 14 methods
// Required methods
fn create_directory(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>
) -> Result<()>;
fn create_file(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>,
content: String
) -> Result<()>;
fn create_symlink(
&mut self,
path: impl AsRef<Utf8Path>,
target: impl AsRef<Utf8Path>
) -> Result<()>;
fn exists(&self, path: impl AsRef<Utf8Path>) -> bool;
fn is_directory(&self, path: impl AsRef<Utf8Path>) -> bool;
fn is_file(&self, path: impl AsRef<Utf8Path>) -> bool;
fn is_link(&self, path: impl AsRef<Utf8Path>) -> bool;
fn list_directory(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<String>>;
fn read_file(&self, path: impl AsRef<Utf8Path>) -> Result<String>;
fn read_link(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf>;
fn attributes(&self, path: impl AsRef<Utf8Path>) -> Result<Attrs<'_>>;
fn set_attributes(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>
) -> Result<()>;
// Provided methods
fn create_directory_all(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>
) -> Result<()> { ... }
fn canonicalize(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf> { ... }
}
Expand description
Operations of a file system
Required Methods§
sourcefn create_directory(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>
) -> Result<()>
fn create_directory( &mut self, path: impl AsRef<Utf8Path>, attrs: SetAttrs<'_> ) -> Result<()>
Create a directory at the given path, with any number of attributes set
sourcefn create_file(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>,
content: String
) -> Result<()>
fn create_file( &mut self, path: impl AsRef<Utf8Path>, attrs: SetAttrs<'_>, content: String ) -> Result<()>
Create a file with the given content and any number of attributes set
sourcefn create_symlink(
&mut self,
path: impl AsRef<Utf8Path>,
target: impl AsRef<Utf8Path>
) -> Result<()>
fn create_symlink( &mut self, path: impl AsRef<Utf8Path>, target: impl AsRef<Utf8Path> ) -> Result<()>
Create a symlink pointing to the given target
sourcefn is_directory(&self, path: impl AsRef<Utf8Path>) -> bool
fn is_directory(&self, path: impl AsRef<Utf8Path>) -> bool
Returns true if the path is a directory
sourcefn is_file(&self, path: impl AsRef<Utf8Path>) -> bool
fn is_file(&self, path: impl AsRef<Utf8Path>) -> bool
Returns true if the path is a regular file
sourcefn is_link(&self, path: impl AsRef<Utf8Path>) -> bool
fn is_link(&self, path: impl AsRef<Utf8Path>) -> bool
Returns true if the path is a symbolic link
sourcefn list_directory(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<String>>
fn list_directory(&self, path: impl AsRef<Utf8Path>) -> Result<Vec<String>>
Lists the contents of the given directory
sourcefn read_file(&self, path: impl AsRef<Utf8Path>) -> Result<String>
fn read_file(&self, path: impl AsRef<Utf8Path>) -> Result<String>
Reads the contents of the given file
sourcefn read_link(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf>
fn read_link(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf>
Reads the path pointed to by the given symbolic link
sourcefn attributes(&self, path: impl AsRef<Utf8Path>) -> Result<Attrs<'_>>
fn attributes(&self, path: impl AsRef<Utf8Path>) -> Result<Attrs<'_>>
Returns the attributes of the given file, directory
If the path is a symlink, the file/directory pointed to by the symlink will be checked and its attributes returned (i.e. paths are dereferenced)
Provided Methods§
sourcefn create_directory_all(
&mut self,
path: impl AsRef<Utf8Path>,
attrs: SetAttrs<'_>
) -> Result<()>
fn create_directory_all( &mut self, path: impl AsRef<Utf8Path>, attrs: SetAttrs<'_> ) -> Result<()>
Create a directory and all of its parents
sourcefn canonicalize(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf>
fn canonicalize(&self, path: impl AsRef<Utf8Path>) -> Result<Utf8PathBuf>
Returns the path after following all symlinks, normalized and absolute