pub trait PathInfo {
Show 26 methods
// Required methods
fn as_path(&self) -> &Path;
fn to_arc_pathbuf(&self) -> Arc<PathBuf>;
// Provided methods
fn as_os_str(&self) -> &OsStr { ... }
fn to_str(&self) -> Option<&str> { ... }
fn to_string_lossy(&self) -> Cow<'_, str> { ... }
fn is_absolute(&self) -> bool { ... }
fn is_relative(&self) -> bool { ... }
fn has_root(&self) -> bool { ... }
fn ancestors(&self) -> Ancestors<'_> { ... }
fn file_name(&self) -> Option<&OsStr> { ... }
fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
where P: AsRef<Path> { ... }
fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool { ... }
fn ends_with<P: AsRef<Path>>(&self, base: P) -> bool { ... }
fn file_stem(&self) -> Option<&OsStr> { ... }
fn extension(&self) -> Option<&OsStr> { ... }
fn components(&self) -> Components<'_> { ... }
fn iter(&self) -> Iter<'_> { ... }
fn display(&self) -> Display<'_> { ... }
fn metadata(&self) -> Result<Metadata> { ... }
fn symlink_metadata(&self) -> Result<Metadata> { ... }
fn exists(&self) -> bool { ... }
fn is_file(&self) -> bool { ... }
fn is_dir(&self) -> bool { ... }
fn read_link(&self) -> Result<PathBuf> { ... }
fn canonicalize(&self) -> Result<PathAbs> { ... }
fn parent(&self) -> Result<&Path> { ... }
}
Expand description
Methods that return information about a path.
This trait provides the familiar methods from std::path::Path
for the Path*
types. These methods take the same parameters and return
the same types as the originals in the standard library, except where
noted.
As a general rule, methods that can return an error will return a rich
path_abs::Error
instead of a std::io::Error
(although it will
automatically convert into a std::io::Error
with ?
if needed).
Required Methods§
Provided Methods§
fn as_os_str(&self) -> &OsStr
fn to_str(&self) -> Option<&str>
fn to_string_lossy(&self) -> Cow<'_, str>
fn is_absolute(&self) -> bool
fn is_relative(&self) -> bool
fn has_root(&self) -> bool
fn ancestors(&self) -> Ancestors<'_>
fn file_name(&self) -> Option<&OsStr>
fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool
fn ends_with<P: AsRef<Path>>(&self, base: P) -> bool
fn file_stem(&self) -> Option<&OsStr>
fn extension(&self) -> Option<&OsStr>
fn components(&self) -> Components<'_>
fn iter(&self) -> Iter<'_>
fn display(&self) -> Display<'_>
Sourcefn metadata(&self) -> Result<Metadata>
fn metadata(&self) -> Result<Metadata>
Queries the file system to get information about a file, directory, etc.
The same as std::path::Path::metadata()
, except that it returns a
rich path_abs::Error
when a problem is encountered.
Sourcefn symlink_metadata(&self) -> Result<Metadata>
fn symlink_metadata(&self) -> Result<Metadata>
Queries the metadata about a file without following symlinks.
The same as std::path::Path::symlink_metadata()
, except that it
returns a rich path_abs::Error
when a problem is encountered.
fn exists(&self) -> bool
fn is_file(&self) -> bool
fn is_dir(&self) -> bool
Sourcefn read_link(&self) -> Result<PathBuf>
fn read_link(&self) -> Result<PathBuf>
Reads a symbolic link, returning the path that the link points to.
The same as std::path::Path::read_link()
, except that it returns a
rich path_abs::Error
when a problem is encountered.
[`std::path::Pathdoc.rust-lang.org/stable/std/path/struct.Path.html#method.read_link
Sourcefn canonicalize(&self) -> Result<PathAbs>
fn canonicalize(&self) -> Result<PathAbs>
Returns the canonical, absolute form of the path with all intermediate components normalized and symbolic links resolved.
The same as std::path::Path::canonicalize()
,
- On success, returns a
path_abs::PathAbs
instead of aPathBuf
- returns a rich
path_abs::Error
when a problem is encountered
Sourcefn parent(&self) -> Result<&Path>
fn parent(&self) -> Result<&Path>
Returns the path without its final component, if there is one.
The same as std::path::Path::parent()
, except that it returns a
Result
with a rich path_abs::Error
when a problem is encountered.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.