Skip to main content

PathExt

Trait PathExt 

Source
pub trait PathExt {
Show 85 methods // Required methods fn base(&self) -> Result<&Path>; fn with_base(&self, base: impl AsRef<Path>) -> Cow<'_, Path>; fn file_suffix(&self) -> Option<&OsStr>; fn absolute(&self) -> Result<PathBuf>; fn metadata(&self) -> Result<Metadata>; fn symlink_metadata(&self) -> Result<Metadata>; fn canonicalize(&self) -> Result<PathBuf>; fn read_link(&self) -> Result<PathBuf>; fn read_dir(&self) -> Result<ReadDir>; fn try_exists(&self) -> Result<bool>; fn try_is_file(&self) -> Result<bool>; fn try_is_dir(&self) -> Result<bool>; fn try_is_symlink(&self) -> Result<bool>; fn metadata_if_exists(&self) -> Result<Option<Metadata>>; fn symlink_metadata_if_exists(&self) -> Result<Option<Metadata>>; fn canonicalize_if_exists(&self) -> Result<Option<PathBuf>>; fn read_link_if_exists(&self) -> Result<Option<PathBuf>>; fn read_dir_if_exists(&self) -> Result<Option<ReadDir>>; fn exists_nofollow(&self) -> bool; fn is_file_nofollow(&self) -> bool; fn is_dir_nofollow(&self) -> bool; fn try_exists_nofollow(&self) -> Result<bool>; fn try_is_file_nofollow(&self) -> Result<bool>; fn try_is_dir_nofollow(&self) -> Result<bool>; fn try_is_read_link_broken(&self) -> Result<bool>; fn try_is_read_link_broken_if_exists(&self) -> Result<Option<bool>>; fn try_is_read_dir_empty(&self) -> Result<bool>; fn try_is_read_dir_empty_if_exists(&self) -> Result<Option<bool>>; fn create_new(&self) -> Result<File>; fn create_new_if_not_exists(&self) -> Result<Option<File>>; fn create(&self) -> Result<File>; fn create_if_not_exists(&self) -> Result<Option<File>>; fn open(&self) -> Result<File>; fn open_if_exists(&self) -> Result<Option<File>>; fn read(&self) -> Result<Vec<u8>>; fn read_if_exists(&self) -> Result<Option<Vec<u8>>>; fn read_to_string(&self) -> Result<String>; fn read_to_string_if_exists(&self) -> Result<Option<String>>; fn read_lines(&self) -> Result<Lines<BufReader<File>>>; fn read_lines_if_exists(&self) -> Result<Option<Lines<BufReader<File>>>>; fn create_dir_all(self) -> Result<Self> where Self: Sized; fn create_dir(self) -> Result<Self> where Self: Sized; fn create_dir_if_not_exists(self) -> Result<Option<Self>> where Self: Sized; fn write_new(self, contents: impl AsRef<[u8]>) -> Result<Self> where Self: Sized; fn write_new_if_not_exists( self, contents: impl AsRef<[u8]>, ) -> Result<Option<Self>> where Self: Sized; fn write(self, contents: impl AsRef<[u8]>) -> Result<Self> where Self: Sized; fn write_if_exists(self, contents: impl AsRef<[u8]>) -> Result<Option<Self>> where Self: Sized; fn append(self, contents: impl AsRef<[u8]>) -> Result<Self> where Self: Sized; fn append_if_exists( self, contents: impl AsRef<[u8]>, ) -> Result<Option<Self>> where Self: Sized; fn copy(self, to: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn copy_if_exists(self, to: impl AsRef<Path>) -> Result<Option<Self>> where Self: Sized; fn rename(self, to: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn rename_if_exists(self, to: impl AsRef<Path>) -> Result<Option<Self>> where Self: Sized; fn remove_file(self) -> Result<Self> where Self: Sized; fn remove_file_if_exists(self) -> Result<Option<Self>> where Self: Sized; fn remove_dir(self) -> Result<Self> where Self: Sized; fn remove_dir_if_exists(self) -> Result<Option<Self>> where Self: Sized; fn remove_dir_all(self) -> Result<Self> where Self: Sized; fn remove_dir_all_if_exists(self) -> Result<Option<Self>> where Self: Sized; fn hard_link(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn hard_link_if_exists(self, link: impl AsRef<Path>) -> Result<Option<Self>> where Self: Sized; fn hard_link_atomic(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn hard_link_atomic_if_exists( self, link: impl AsRef<Path>, ) -> Result<Option<Self>> where Self: Sized; fn symlink(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn symlink_atomic(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn symlink_absolute(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn symlink_absolute_atomic(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn symlink_relative(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn symlink_relative_atomic(self, link: impl AsRef<Path>) -> Result<Self> where Self: Sized; fn set_permissions(self, perm: Permissions) -> Result<Self> where Self: Sized; fn set_permissions_if_exists( self, perm: Permissions, ) -> Result<Option<Self>> where Self: Sized; fn set_permissions_readonly(self, readonly: bool) -> Result<Self> where Self: Sized; fn set_permissions_readonly_if_exists( self, readonly: bool, ) -> Result<Option<Self>> where Self: Sized; fn set_permissions_mode(self, mode: u32) -> Result<Self> where Self: Sized; fn set_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>> where Self: Sized; fn add_permissions_mode(self, mode: u32) -> Result<Self> where Self: Sized; fn add_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>> where Self: Sized; fn remove_permissions_mode(self, mode: u32) -> Result<Self> where Self: Sized; fn remove_permissions_mode_if_exists( self, mode: u32, ) -> Result<Option<Self>> where Self: Sized; fn chown(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self> where Self: Sized; fn chown_if_exists( self, uid: Option<u32>, gid: Option<u32>, ) -> Result<Option<Self>> where Self: Sized; fn chown_nofollow(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self> where Self: Sized; fn chown_nofollow_if_exists( self, uid: Option<u32>, gid: Option<u32>, ) -> Result<Option<Self>> where Self: Sized; fn chroot(self) -> Result<Self> where Self: Sized; fn chroot_if_exists(self) -> Result<Option<Self>> where Self: Sized;
}

Required Methods§

Source

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

Source

fn with_base(&self, base: impl AsRef<Path>) -> Cow<'_, Path>

Source

fn file_suffix(&self) -> Option<&OsStr>

Source

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

Source

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

Source

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

Source

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

Source

fn try_exists(&self) -> Result<bool>

Source

fn try_is_file(&self) -> Result<bool>

Source

fn try_is_dir(&self) -> Result<bool>

Source

fn metadata_if_exists(&self) -> Result<Option<Metadata>>

Source

fn canonicalize_if_exists(&self) -> Result<Option<PathBuf>>

Source

fn read_dir_if_exists(&self) -> Result<Option<ReadDir>>

Source

fn exists_nofollow(&self) -> bool

Source

fn is_file_nofollow(&self) -> bool

Source

fn is_dir_nofollow(&self) -> bool

Source

fn try_exists_nofollow(&self) -> Result<bool>

Source

fn try_is_file_nofollow(&self) -> Result<bool>

Source

fn try_is_dir_nofollow(&self) -> Result<bool>

Source

fn try_is_read_dir_empty(&self) -> Result<bool>

Source

fn try_is_read_dir_empty_if_exists(&self) -> Result<Option<bool>>

Source

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

Source

fn create_new_if_not_exists(&self) -> Result<Option<File>>

Source

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

Source

fn create_if_not_exists(&self) -> Result<Option<File>>

Source

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

Source

fn open_if_exists(&self) -> Result<Option<File>>

Source

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

Source

fn read_if_exists(&self) -> Result<Option<Vec<u8>>>

Source

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

Source

fn read_to_string_if_exists(&self) -> Result<Option<String>>

Source

fn read_lines(&self) -> Result<Lines<BufReader<File>>>

Source

fn read_lines_if_exists(&self) -> Result<Option<Lines<BufReader<File>>>>

Source

fn create_dir_all(self) -> Result<Self>
where Self: Sized,

Source

fn create_dir(self) -> Result<Self>
where Self: Sized,

Source

fn create_dir_if_not_exists(self) -> Result<Option<Self>>
where Self: Sized,

Source

fn write_new(self, contents: impl AsRef<[u8]>) -> Result<Self>
where Self: Sized,

Source

fn write_new_if_not_exists( self, contents: impl AsRef<[u8]>, ) -> Result<Option<Self>>
where Self: Sized,

Source

fn write(self, contents: impl AsRef<[u8]>) -> Result<Self>
where Self: Sized,

Source

fn write_if_exists(self, contents: impl AsRef<[u8]>) -> Result<Option<Self>>
where Self: Sized,

Source

fn append(self, contents: impl AsRef<[u8]>) -> Result<Self>
where Self: Sized,

Source

fn append_if_exists(self, contents: impl AsRef<[u8]>) -> Result<Option<Self>>
where Self: Sized,

Source

fn copy(self, to: impl AsRef<Path>) -> Result<Self>
where Self: Sized,

Source

fn copy_if_exists(self, to: impl AsRef<Path>) -> Result<Option<Self>>
where Self: Sized,

Source

fn rename(self, to: impl AsRef<Path>) -> Result<Self>
where Self: Sized,

Source

fn rename_if_exists(self, to: impl AsRef<Path>) -> Result<Option<Self>>
where Self: Sized,

Source

fn remove_file(self) -> Result<Self>
where Self: Sized,

Source

fn remove_file_if_exists(self) -> Result<Option<Self>>
where Self: Sized,

Source

fn remove_dir(self) -> Result<Self>
where Self: Sized,

Source

fn remove_dir_if_exists(self) -> Result<Option<Self>>
where Self: Sized,

Source

fn remove_dir_all(self) -> Result<Self>
where Self: Sized,

Source

fn remove_dir_all_if_exists(self) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Available on Unix only.
Available on Unix only.
Available on Unix only.
Available on Unix only.
Available on Unix only.
Source

fn set_permissions(self, perm: Permissions) -> Result<Self>
where Self: Sized,

Source

fn set_permissions_if_exists(self, perm: Permissions) -> Result<Option<Self>>
where Self: Sized,

Source

fn set_permissions_readonly(self, readonly: bool) -> Result<Self>
where Self: Sized,

Source

fn set_permissions_readonly_if_exists( self, readonly: bool, ) -> Result<Option<Self>>
where Self: Sized,

Source

fn set_permissions_mode(self, mode: u32) -> Result<Self>
where Self: Sized,

Available on Unix only.
Source

fn set_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Source

fn add_permissions_mode(self, mode: u32) -> Result<Self>
where Self: Sized,

Available on Unix only.
Source

fn add_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Source

fn remove_permissions_mode(self, mode: u32) -> Result<Self>
where Self: Sized,

Available on Unix only.
Source

fn remove_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Source

fn chown(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self>
where Self: Sized,

Available on Unix only.
Source

fn chown_if_exists( self, uid: Option<u32>, gid: Option<u32>, ) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Source

fn chown_nofollow(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self>
where Self: Sized,

Available on Unix only.
Source

fn chown_nofollow_if_exists( self, uid: Option<u32>, gid: Option<u32>, ) -> Result<Option<Self>>
where Self: Sized,

Available on Unix only.
Source

fn chroot(self) -> Result<Self>
where Self: Sized,

Available on Unix and non-Fuchsia only.
Source

fn chroot_if_exists(self) -> Result<Option<Self>>
where Self: Sized,

Available on Unix and non-Fuchsia only.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: AsRef<Path>> PathExt for T