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§
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,
Available on Unix only.
fn symlink_atomic(self, link: impl AsRef<Path>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn symlink_absolute(self, link: impl AsRef<Path>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn symlink_absolute_atomic(self, link: impl AsRef<Path>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn symlink_relative(self, link: impl AsRef<Path>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn symlink_relative_atomic(self, link: impl AsRef<Path>) -> Result<Self>where
Self: Sized,
Available on Unix only.
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,
Available on Unix only.
fn set_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>where
Self: Sized,
Available on Unix only.
fn add_permissions_mode(self, mode: u32) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn add_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>where
Self: Sized,
Available on Unix only.
fn remove_permissions_mode(self, mode: u32) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn remove_permissions_mode_if_exists(self, mode: u32) -> Result<Option<Self>>where
Self: Sized,
Available on Unix only.
fn chown(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn chown_if_exists(
self,
uid: Option<u32>,
gid: Option<u32>,
) -> Result<Option<Self>>where
Self: Sized,
Available on Unix only.
fn chown_nofollow(self, uid: Option<u32>, gid: Option<u32>) -> Result<Self>where
Self: Sized,
Available on Unix only.
fn chown_nofollow_if_exists(
self,
uid: Option<u32>,
gid: Option<u32>,
) -> Result<Option<Self>>where
Self: Sized,
Available on Unix only.
fn chroot(self) -> Result<Self>where
Self: Sized,
Available on Unix and non-Fuchsia only.
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".