Trait path_abs::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.

Implementations on Foreign Types§

source§

impl PathInfo for Path

Implementors§

source§

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