path_abs

Trait PathInfo

Source
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§

Source

fn as_os_str(&self) -> &OsStr

Source

fn to_str(&self) -> Option<&str>

Source

fn to_string_lossy(&self) -> Cow<'_, str>

Source

fn is_absolute(&self) -> bool

Source

fn is_relative(&self) -> bool

Source

fn has_root(&self) -> bool

Source

fn ancestors(&self) -> Ancestors<'_>

Source

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

Source

fn strip_prefix<P>(&self, base: P) -> Result<&Path, StripPrefixError>
where P: AsRef<Path>,

Source

fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool

Source

fn ends_with<P: AsRef<Path>>(&self, base: P) -> bool

Source

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

Source

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

Source

fn components(&self) -> Components<'_>

Source

fn iter(&self) -> Iter<'_>

Source

fn display(&self) -> Display<'_>

Source

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.

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.

Source

fn exists(&self) -> bool

Source

fn is_file(&self) -> bool

Source

fn is_dir(&self) -> bool

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

Source

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 a PathBuf
  • returns a rich path_abs::Error when a problem is encountered
Source

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.

Implementations on Foreign Types§

Source§

impl PathInfo for Path

Implementors§

Source§

impl<T> PathInfo for T
where T: Clone + Borrow<PathBuf> + Into<Arc<PathBuf>>,