Path

Struct Path 

Source
pub struct Path<State: PathState> { /* private fields */ }
Available on Linux only.

Implementations§

Source§

impl Path<Abs>

Source§

impl<S: PathState> Path<S>

Source

pub fn new<'a, O: AsRef<OsStr> + ?Sized>(value: &'a O) -> Cow<'a, Path<S>>

Source

pub fn from_checked<O: AsRef<OsStr> + ?Sized>(value: &O) -> Option<&Path<S>>

Source

pub unsafe fn from_unchecked<O: AsRef<OsStr> + ?Sized>(value: &O) -> &Self

Source

pub unsafe fn from_unchecked_mut<O: AsMut<OsStr> + ?Sized>( value: &mut O, ) -> &mut Self

Source

pub const fn display<'a>(&'a self) -> DisplayPath<'a, S>

Source

pub fn len(&self) -> NonZero<usize>

Source

pub const fn as_os_str(&self) -> &OsStr

Source

pub fn as_os_str_no_lead(&self) -> &OsStr

Source

pub fn as_bytes(&self) -> &[u8]

Source

pub fn basename(&self) -> &OsStr

Returns the basename of this path (the OsStr following the last / in the path). This OsStr won’t contain any instances of /.

See parent() for more info.

Source

pub fn parent(&self) -> &Self

Returns the parent directory of this path (lexically speaking). The result is a Path with basename and the preceding slash removed, such that the following holds for any path.

let owned = OwnedPath::<Abs>::from("/my/path");
let path: &Path<Abs> = &owned;
let new_path = path.parent().join(Path::new(path.basename()));
assert_eq!(path, new_path);

Because this method is the counterpart of basename and basename won’t contain any /, the behavior when calling these methods on "/" is as follows:

assert_eq!(Path::root().basename(), "");
assert_eq!(Path::root().parent(), Path::root());

This behavior is also consistent with Unix defaults: the .. entry in the root directory refers to the root itself.

Source

pub fn join<P: AsRef<Path<Rel>>>(&self, other: P) -> OwnedPath<S>

Source

pub fn relative_to(&self, other: &Self) -> Option<&Path<Rel>>

Source

pub fn components<'a>(&'a self) -> Components<'a, S>

Creates an Iterator over the components of a Path. This iterator produces Path<Rel>s representing each /-separated string in the Path, from left to right.

Source

pub fn ancestors<'a>(&'a self) -> Ancestors<'a, S>

Creates an Iterator over the ancestors of a Path. This iterator produces Path<S>s representing each directory in the Path ordered with descending depth and ending with the Path itself.

Source§

impl Path<Rel>

Source

pub fn dot_slash() -> &'static Path<Rel>

Source

pub fn resolve(&self, target: OwnedPath<Abs>) -> OwnedPath<Abs>

Source

pub fn resolve_root(&self) -> OwnedPath<Abs>

Source

pub fn resolve_home(&self) -> Option<OwnedPath<Abs>>

Source

pub fn resolve_cwd(&self) -> Option<OwnedPath<Abs>>

Source

pub fn metadata( &self, relative_to: Directory, ) -> Result<Metadata, PathOrMetadataError>

Source

pub fn metadata_no_follow( &self, relative_to: Directory, ) -> Result<Metadata, PathOrMetadataError>

Trait Implementations§

Source§

impl<S: PathState> AsRef<Path<S>> for OwnedPath<S>

Source§

fn as_ref(&self) -> &Path<S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: PathState> AsRef<Path<S>> for Path<S>

Source§

fn as_ref(&self) -> &Path<S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S: PathState> Borrow<Path<S>> for OwnedPath<S>

Source§

fn borrow(&self) -> &Path<S>

Immutably borrows from an owned value. Read more
Source§

impl<S: PathState> Debug for Path<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: PathState> From<&Path<S>> for OwnedPath<S>

Source§

fn from(value: &Path<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: PathState> Ord for Path<S>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl<S: PathState> PartialEq<OwnedPath<S>> for Path<S>

Source§

fn eq(&self, other: &OwnedPath<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: PathState> PartialEq<Path<S>> for OwnedPath<S>

Source§

fn eq(&self, other: &Path<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: PathState> PartialEq for Path<S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: PathState> PartialOrd<OwnedPath<S>> for Path<S>

Source§

fn partial_cmp(&self, other: &OwnedPath<S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: PathState> PartialOrd<Path<S>> for OwnedPath<S>

Source§

fn partial_cmp(&self, other: &Path<S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: PathState> PartialOrd for Path<S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S: PathState> ToOwned for Path<S>

Source§

type Owned = OwnedPath<S>

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<S: PathState> Eq for Path<S>

Auto Trait Implementations§

§

impl<State> Freeze for Path<State>

§

impl<State> RefUnwindSafe for Path<State>

§

impl<State> Send for Path<State>

§

impl<State> !Sized for Path<State>

§

impl<State> Sync for Path<State>

§

impl<State> Unpin for Path<State>

§

impl<State> UnwindSafe for Path<State>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more