Struct iref::Path[][src]

pub struct Path<'a> { /* fields omitted */ }

Implementations

Byte length of the path.

The inner data length (in bytes), without the trailing / if the path is open.

Returns a reference to the byte representation of the path.

Converts this path into the underlying bytes slice.

Get the underlying path slice as a string slice.

Convert this path into the underlying path 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.

Checks if the path ends with a / but is not equal to /.

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.

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.

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

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.