pub struct Path<'a> { /* private fields */ }Expand description
Path provides a copy-on-write-style path that is built around UTF8 strings.
Implementations§
Source§impl<'a> Path<'a>
impl<'a> Path<'a>
Sourcepub fn into_owned(self) -> Path<'static>
pub fn into_owned(self) -> Path<'static>
Convert the path into an owned path.
Sourcepub fn basename(&self) -> Path<'_>
pub fn basename(&self) -> Path<'_>
Compute the basename of the path. This is guaraneed to be a non-empty path component (falling back to “.” for paths that end with “/”).
Sourcepub fn dirname(&self) -> Path<'_>
pub fn dirname(&self) -> Path<'_>
Compute the dirname of the path. This is guaranteed to be a non-empty path component (falling back to “.” or “/” for single-component paths).
Sourcepub fn has_root(&self) -> bool
pub fn has_root(&self) -> bool
True if the path begins with some number of slashes, other than the POSIX-exception of //.
Sourcepub fn has_app_defined(&self) -> bool
pub fn has_app_defined(&self) -> bool
True if the path begins with //, but not ///.
Sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
True if the path contains no “.” components; and, is absolute and has no “..” components, or is relative and has all “..” components at the start.
Sourcepub fn join<'b, 'c>(&self, with: impl Into<Path<'b>>) -> Path<'c>where
'a: 'c,
'b: 'c,
pub fn join<'b, 'c>(&self, with: impl Into<Path<'b>>) -> Path<'c>where
'a: 'c,
'b: 'c,
Join to this path another path. Follows standard path rules where if the joined-with path is absolute, the first path is discarded.
Sourcepub fn strip_prefix<'b>(&self, prefix: impl Into<Path<'b>>) -> Option<Path<'_>>
pub fn strip_prefix<'b>(&self, prefix: impl Into<Path<'b>>) -> Option<Path<'_>>
Strip a prefix from the path. The prefix and path are allowed to be non-normal and will have “.” components dropped from consideration.
Sourcepub fn split(&self) -> (Path<'_>, Path<'_>)
pub fn split(&self) -> (Path<'_>, Path<'_>)
Split the path into basename and dirname components.
Sourcepub fn components(&self) -> impl Iterator<Item = Component<'_>>
pub fn components(&self) -> impl Iterator<Item = Component<'_>>
Return an iterator ovre the path components. A path with a basename of “.” will always end with Component::CurDir.
Sourcepub fn cwd() -> Option<Path<'a>>
pub fn cwd() -> Option<Path<'a>>
Return the current working directory, if it can be fetched and converted to unicode without error.
Sourcepub fn canonicalize(&self) -> Result<Path<'static>, Error>
pub fn canonicalize(&self) -> Result<Path<'static>, Error>
Return the canonicalized path with all intermediate components normalized and symbolic links resolved.