Trait anyhow_std::PathAnyhow
source · pub trait PathAnyhow {
Show 27 methods
// Required methods
fn to_str_anyhow(&self) -> Result<&str>;
fn parent_anyhow(&self) -> Result<&Path>;
fn file_name_anyhow(&self) -> Result<&OsStr>;
fn strip_prefix_anyhow<P>(&self, base: P) -> Result<&Path>
where P: AsRef<Path>;
fn file_stem_anyhow(&self) -> Result<&OsStr>;
fn extension_anyhow(&self) -> Result<&OsStr>;
fn metadata_anyhow(&self) -> Result<Metadata>;
fn symlink_metadata_anyhow(&self) -> Result<Metadata>;
fn canonicalize_anyhow(&self) -> Result<PathBuf>;
fn read_link_anyhow(&self) -> Result<PathBuf>;
fn read_dir_anyhow(&self) -> Result<ReadDir>;
fn copy_anyhow<P>(&self, to: P) -> Result<u64>
where P: AsRef<Path>;
fn create_dir_anyhow(&self) -> Result<()>;
fn create_dir_all_anyhow(&self) -> Result<()>;
fn hard_link_anyhow<P>(&self, link: P) -> Result<()>
where P: AsRef<Path>;
fn read_anyhow(&self) -> Result<Vec<u8>>;
fn read_to_string_anyhow(&self) -> Result<String>;
fn remove_dir_anyhow(&self) -> Result<()>;
fn remove_dir_all_anyhow(&self) -> Result<()>;
fn remove_file_anyhow(&self) -> Result<()>;
fn rename_anyhow<P>(&self, to: P) -> Result<()>
where P: AsRef<Path>;
fn set_permissions_anyhow(&self, perm: Permissions) -> Result<()>;
fn set_readonly_anyhow(&self, readonly: bool) -> Result<()>;
fn write_anyhow<C>(&self, contents: C) -> Result<()>
where C: AsRef<[u8]>;
fn set_to_current_dir_anyhow(&self) -> Result<()>;
fn open_file_anyhow(&self) -> Result<File>;
fn create_file_anyhow(&self) -> Result<File>;
}
Required Methods§
sourcefn to_str_anyhow(&self) -> Result<&str>
fn to_str_anyhow(&self) -> Result<&str>
Wrap Path::to_str, providing the path as error context
sourcefn parent_anyhow(&self) -> Result<&Path>
fn parent_anyhow(&self) -> Result<&Path>
Wrap Path::parent, providing the path as error context
sourcefn file_name_anyhow(&self) -> Result<&OsStr>
fn file_name_anyhow(&self) -> Result<&OsStr>
Wrap Path::file_name, providing the path as error context
sourcefn strip_prefix_anyhow<P>(&self, base: P) -> Result<&Path>where
P: AsRef<Path>,
fn strip_prefix_anyhow<P>(&self, base: P) -> Result<&Path>where P: AsRef<Path>,
Wrap Path::strip_prefix, providing the path and base
as error context
sourcefn file_stem_anyhow(&self) -> Result<&OsStr>
fn file_stem_anyhow(&self) -> Result<&OsStr>
Wrap Path::file_stem, providing the path as error context
sourcefn extension_anyhow(&self) -> Result<&OsStr>
fn extension_anyhow(&self) -> Result<&OsStr>
Wrap Path::extension, providing the path as error context
sourcefn metadata_anyhow(&self) -> Result<Metadata>
fn metadata_anyhow(&self) -> Result<Metadata>
Wrap Path::metadata, providing the path as error context
sourcefn symlink_metadata_anyhow(&self) -> Result<Metadata>
fn symlink_metadata_anyhow(&self) -> Result<Metadata>
Wrap Path::symlink_metadata, providing the path as error context
sourcefn canonicalize_anyhow(&self) -> Result<PathBuf>
fn canonicalize_anyhow(&self) -> Result<PathBuf>
Wrap Path::canonicalize, providing the path as error context
sourcefn read_link_anyhow(&self) -> Result<PathBuf>
fn read_link_anyhow(&self) -> Result<PathBuf>
Wrap Path::read_link, providing the path as error context
sourcefn read_dir_anyhow(&self) -> Result<ReadDir>
fn read_dir_anyhow(&self) -> Result<ReadDir>
Wrap Path::read_dir, providing the path as error context
sourcefn copy_anyhow<P>(&self, to: P) -> Result<u64>where
P: AsRef<Path>,
fn copy_anyhow<P>(&self, to: P) -> Result<u64>where P: AsRef<Path>,
Wrap std::fs::copy from self
to to
, providing self
and to
as error context
sourcefn create_dir_anyhow(&self) -> Result<()>
fn create_dir_anyhow(&self) -> Result<()>
Wrap std::fs::create_dir, providing the path as error context
sourcefn create_dir_all_anyhow(&self) -> Result<()>
fn create_dir_all_anyhow(&self) -> Result<()>
Wrap std::fs::create_dir_all, providing the path as error context
sourcefn hard_link_anyhow<P>(&self, link: P) -> Result<()>where
P: AsRef<Path>,
fn hard_link_anyhow<P>(&self, link: P) -> Result<()>where P: AsRef<Path>,
Wrap std::fs::hard_link, providing self
and link
as error context
sourcefn read_anyhow(&self) -> Result<Vec<u8>>
fn read_anyhow(&self) -> Result<Vec<u8>>
Wrap std::fs::read, providing the path as error context
sourcefn read_to_string_anyhow(&self) -> Result<String>
fn read_to_string_anyhow(&self) -> Result<String>
Wrap std::fs::read_to_string, providing the path as error context
sourcefn remove_dir_anyhow(&self) -> Result<()>
fn remove_dir_anyhow(&self) -> Result<()>
Wrap std::fs::remove_dir, providing the path as error context
sourcefn remove_dir_all_anyhow(&self) -> Result<()>
fn remove_dir_all_anyhow(&self) -> Result<()>
Wrap std::fs::remove_dir_all, providing the path as error context
sourcefn remove_file_anyhow(&self) -> Result<()>
fn remove_file_anyhow(&self) -> Result<()>
Wrap std::fs::remove_file, providing the path as error context
sourcefn rename_anyhow<P>(&self, to: P) -> Result<()>where
P: AsRef<Path>,
fn rename_anyhow<P>(&self, to: P) -> Result<()>where P: AsRef<Path>,
Wrap std::fs::rename, providing self
and to
as error context
sourcefn set_permissions_anyhow(&self, perm: Permissions) -> Result<()>
fn set_permissions_anyhow(&self, perm: Permissions) -> Result<()>
Wrap std::fs::set_permissions, providing the path as error context
sourcefn set_readonly_anyhow(&self, readonly: bool) -> Result<()>
fn set_readonly_anyhow(&self, readonly: bool) -> Result<()>
Toggle read-only permission for the path
This method factors out the complexity of retrieving std::fs::Permissions, modifying them, and then setting them.
sourcefn write_anyhow<C>(&self, contents: C) -> Result<()>where
C: AsRef<[u8]>,
fn write_anyhow<C>(&self, contents: C) -> Result<()>where C: AsRef<[u8]>,
Wrap std::fs::write, providing the path as error context
sourcefn set_to_current_dir_anyhow(&self) -> Result<()>
fn set_to_current_dir_anyhow(&self) -> Result<()>
Wrap std::env::set_current_dir, providing the path as error context
sourcefn open_file_anyhow(&self) -> Result<File>
fn open_file_anyhow(&self) -> Result<File>
Open a File in read-only mode wrapping File::open
sourcefn create_file_anyhow(&self) -> Result<File>
fn create_file_anyhow(&self) -> Result<File>
Open a File in write-only mode wrapping File::create