diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/fs-err/src/path.rs | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/fs-err/src/path.rs')
-rw-r--r-- | third_party/rust/fs-err/src/path.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/third_party/rust/fs-err/src/path.rs b/third_party/rust/fs-err/src/path.rs new file mode 100644 index 0000000000..28549a31cf --- /dev/null +++ b/third_party/rust/fs-err/src/path.rs @@ -0,0 +1,43 @@ +use std::fs;
+use std::io;
+use std::path::{Path, PathBuf};
+
+/// Defines aliases on [`Path`](https://doc.rust-lang.org/std/path/struct.Path.html) for `fs_err` functions.
+///
+/// This trait is sealed and can not be implemented by other crates.
+//
+// Because no one else can implement it, we can add methods backwards-compatibly.
+pub trait PathExt: crate::Sealed {
+ /// Wrapper for [`crate::metadata`].
+ fn fs_err_metadata(&self) -> io::Result<fs::Metadata>;
+ /// Wrapper for [`crate::symlink_metadata`].
+ fn fs_err_symlink_metadata(&self) -> io::Result<fs::Metadata>;
+ /// Wrapper for [`crate::canonicalize`].
+ fn fs_err_canonicalize(&self) -> io::Result<PathBuf>;
+ /// Wrapper for [`crate::read_link`].
+ fn fs_err_read_link(&self) -> io::Result<PathBuf>;
+ /// Wrapper for [`crate::read_dir`].
+ fn fs_err_read_dir(&self) -> io::Result<crate::ReadDir>;
+}
+
+impl PathExt for Path {
+ fn fs_err_metadata(&self) -> io::Result<fs::Metadata> {
+ crate::metadata(self)
+ }
+
+ fn fs_err_symlink_metadata(&self) -> io::Result<fs::Metadata> {
+ crate::symlink_metadata(self)
+ }
+
+ fn fs_err_canonicalize(&self) -> io::Result<PathBuf> {
+ crate::canonicalize(self)
+ }
+
+ fn fs_err_read_link(&self) -> io::Result<PathBuf> {
+ crate::read_link(self)
+ }
+
+ fn fs_err_read_dir(&self) -> io::Result<crate::ReadDir> {
+ crate::read_dir(self)
+ }
+}
|