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

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§