Struct iref::Path [−][src]
pub struct Path<'a> { /* fields omitted */ }
Implementations
The inner data length (in bytes), without the trailing /
if the path is open.
Converts this path into the underlying bytes slice.
Get the underlying path slice as a percent-encoded string slice.
Get the path slice as an IRI reference.
Convert this path into an IRI reference.
Checks if the path is empty.
Returns true
if the path is `` or /
.
Checks if the path is absolute.
A path is absolute if it starts with a /
.
A path is necessarily absolute if the IRI it is contained in contains a non-empty
authority.
Checks if the path is relative.
A path is relative if it does not start with a /
.
A path cannot be relative if the IRI it is contained in contains a non-empty authority.
Return the path directory part.
This correspond to the path without everything after the right most /
.
Produces an iterator over the segments of the IRI path.
Note that this is an IRI path, not an IRI reference path: no normalization occurs with
.
and ..
segments. This is done by the IRI reference resolution function.
Empty segments are preserved: the path a//b
will raise the three segments a
, and `b`. The absolute path `/` has no segments, but the path `/a/` has two segments, `a` and
.
pub fn normalized_segments(&self) -> NormalizedSegments<'_>ⓘNotable traits for NormalizedSegments<'a>impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
pub fn normalized_segments(&self) -> NormalizedSegments<'_>ⓘNotable traits for NormalizedSegments<'a>impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
Iterate over the normalized segments of the path.
Remove the special dot segments ..
and .
from the iteration using the usual path
semantics for dot segments.
This may be expensive for large paths since it will need to internally normalize the path
first.
pub fn into_normalized_segments(self) -> NormalizedSegments<'a>ⓘNotable traits for NormalizedSegments<'a>impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
pub fn into_normalized_segments(self) -> NormalizedSegments<'a>ⓘNotable traits for NormalizedSegments<'a>impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
impl<'a> Iterator for NormalizedSegments<'a> type Item = Segment<'a>;
Consume the path reference and return an iterator over its normalized segments.
Returns the name of the final segment of the path, if there is one.
If the path is a normal file, this is the file name. If it’s the path of a directory, this is the directory name.
This does not consider the normalized version of the path, dot segments are preserved.
Returns the path without its final component, if there is one.
Get the suffix part of this path, if any, with regard to the given prefix path.
Returns Some(suffix)
if this path is of the form prefix/suffix
where prefix
is given
as parameter. Returns None
otherwise.
Both paths are normalized during the process. The result is a normalized suffix path.
Example
use iref::{Path, PathBuf};
let prefix = Path::try_from("/foo/bar").unwrap();
let path = Path::try_from("/foo/bar/baz").unwrap();
let suffix: PathBuf = path.suffix(prefix).unwrap();
assert_eq!(suffix, "baz");
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for Path<'a>
impl<'a> UnwindSafe for Path<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more