From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- third_party/rust/fs-err/src/path.rs | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 third_party/rust/fs-err/src/path.rs (limited to 'third_party/rust/fs-err/src/path.rs') 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; + /// Wrapper for [`crate::symlink_metadata`]. + fn fs_err_symlink_metadata(&self) -> io::Result; + /// Wrapper for [`crate::canonicalize`]. + fn fs_err_canonicalize(&self) -> io::Result; + /// Wrapper for [`crate::read_link`]. + fn fs_err_read_link(&self) -> io::Result; + /// Wrapper for [`crate::read_dir`]. + fn fs_err_read_dir(&self) -> io::Result; +} + +impl PathExt for Path { + fn fs_err_metadata(&self) -> io::Result { + crate::metadata(self) + } + + fn fs_err_symlink_metadata(&self) -> io::Result { + crate::symlink_metadata(self) + } + + fn fs_err_canonicalize(&self) -> io::Result { + crate::canonicalize(self) + } + + fn fs_err_read_link(&self) -> io::Result { + crate::read_link(self) + } + + fn fs_err_read_dir(&self) -> io::Result { + crate::read_dir(self) + } +} -- cgit v1.2.3