Trait 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>;
}
Expand description

Extend Path with anyhow methods

Required Methods§

Source

fn to_str_anyhow(&self) -> Result<&str>

Wrap Path::to_str, providing the path as error context

Source

fn parent_anyhow(&self) -> Result<&Path>

Wrap Path::parent, providing the path as error context

Source

fn file_name_anyhow(&self) -> Result<&OsStr>

Wrap Path::file_name, providing the path as error context

Source

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

Source

fn file_stem_anyhow(&self) -> Result<&OsStr>

Wrap Path::file_stem, providing the path as error context

Source

fn extension_anyhow(&self) -> Result<&OsStr>

Wrap Path::extension, providing the path as error context

Source

fn metadata_anyhow(&self) -> Result<Metadata>

Wrap Path::metadata, providing the path as error context

Wrap Path::symlink_metadata, providing the path as error context

Source

fn canonicalize_anyhow(&self) -> Result<PathBuf>

Wrap Path::canonicalize, providing the path as error context

Wrap Path::read_link, providing the path as error context

Source

fn read_dir_anyhow(&self) -> Result<ReadDir>

Wrap Path::read_dir, providing the path as error context

Source

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

Source

fn create_dir_anyhow(&self) -> Result<()>

Wrap std::fs::create_dir, providing the path as error context

Source

fn create_dir_all_anyhow(&self) -> Result<()>

Wrap std::fs::create_dir_all, providing the path as error context

Wrap std::fs::hard_link, providing self and link as error context

Source

fn read_anyhow(&self) -> Result<Vec<u8>>

Wrap std::fs::read, providing the path as error context

Source

fn read_to_string_anyhow(&self) -> Result<String>

Wrap std::fs::read_to_string, providing the path as error context

Source

fn remove_dir_anyhow(&self) -> Result<()>

Wrap std::fs::remove_dir, providing the path as error context

Source

fn remove_dir_all_anyhow(&self) -> Result<()>

Wrap std::fs::remove_dir_all, providing the path as error context

Source

fn remove_file_anyhow(&self) -> Result<()>

Wrap std::fs::remove_file, providing the path as error context

Source

fn rename_anyhow<P>(&self, to: P) -> Result<()>
where P: AsRef<Path>,

Wrap std::fs::rename, providing self and to as error context

Source

fn set_permissions_anyhow(&self, perm: Permissions) -> Result<()>

Wrap std::fs::set_permissions, providing the path as error context

Source

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.

Source

fn write_anyhow<C>(&self, contents: C) -> Result<()>
where C: AsRef<[u8]>,

Wrap std::fs::write, providing the path as error context

Source

fn set_to_current_dir_anyhow(&self) -> Result<()>

Wrap std::env::set_current_dir, providing the path as error context

Source

fn open_file_anyhow(&self) -> Result<File>

Open a File in read-only mode wrapping File::open

Source

fn create_file_anyhow(&self) -> Result<File>

Open a File in write-only mode wrapping File::create

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.

Implementations on Foreign Types§

Source§

impl PathAnyhow for Path

Source§

fn to_str_anyhow(&self) -> Result<&str>

Source§

fn parent_anyhow(&self) -> Result<&Path>

Source§

fn file_name_anyhow(&self) -> Result<&OsStr>

Source§

fn strip_prefix_anyhow<Q>(&self, prefix: Q) -> Result<&Path>
where Q: AsRef<Path>,

Source§

fn file_stem_anyhow(&self) -> Result<&OsStr>

Source§

fn extension_anyhow(&self) -> Result<&OsStr>

Source§

fn metadata_anyhow(&self) -> Result<Metadata>

Source§

fn canonicalize_anyhow(&self) -> Result<PathBuf>

Source§

fn read_dir_anyhow(&self) -> Result<ReadDir>

Source§

fn copy_anyhow<Q>(&self, copy_to: Q) -> Result<u64>
where Q: AsRef<Path>,

Source§

fn create_dir_anyhow(&self) -> Result<()>

Source§

fn create_dir_all_anyhow(&self) -> Result<()>

Source§

fn read_anyhow(&self) -> Result<Vec<u8>>

Source§

fn read_to_string_anyhow(&self) -> Result<String>

Source§

fn remove_dir_anyhow(&self) -> Result<()>

Source§

fn remove_dir_all_anyhow(&self) -> Result<()>

Source§

fn remove_file_anyhow(&self) -> Result<()>

Source§

fn rename_anyhow<Q>(&self, rename_to: Q) -> Result<()>
where Q: AsRef<Path>,

Source§

fn set_permissions_anyhow(&self, perms: Permissions) -> Result<()>

Source§

fn set_readonly_anyhow(&self, readonly: bool) -> Result<()>

Source§

fn write_anyhow<C>(&self, contents: C) -> Result<()>
where C: AsRef<[u8]>,

Source§

fn set_to_current_dir_anyhow(&self) -> Result<()>

Source§

fn open_file_anyhow(&self) -> Result<File>

Source§

fn create_file_anyhow(&self) -> Result<File>

Implementors§