Struct canonical_path::CanonicalPath[][src]

pub struct CanonicalPath(_);

A reference type for a canonical filesystem path

More specifically: it is at least guaranteed to be canonical at the time it is created. There are potential TOCTTOU problems if the underlying filesystem structure changes after path canonicalization.

Methods

impl CanonicalPath
[src]

Create a canonical path, returning error if the supplied path is not canonical

Create a canonical path from a path, skipping the canonicalization check

We utilize the same unsafe reference conversion tricks as std to convert from AsRef<Path> to AsRef<CanonicalPath>, i.e. &CanonicalPath is a newtype for &Path in the same way &Path is a newtype for &OsStr.

Convert a canonical path reference into an owned CanonicalPathBuf

Return a Path reference.

Return an OsStr reference.

Yields a &str slice if the path is valid unicode.

Return a canonical parent path of this path, or io::Error if the path is the root directory or another canonicalization error occurs.

Returns the final component of the path, if there is one.

Determines whether base is a prefix of self.

Determines whether child is a suffix of self.

Extracts the stem (non-extension) portion of self.file_name.

Extracts the extension of self.file_name, if possible.

Creates an owned CanonicalPathBuf like self but with the given file name.

Creates an owned CanonicalPathBuf like self but with the given extension.

Produces an iterator over the Components of a path

Produces an iterator over the path's components viewed as OsStr slices.

Returns an object that implements Display for safely printing paths that may contain non-Unicode data.

Queries the file system to get information about a file, directory, etc.

Unlike the std version of this method, it will not follow symlinks, since as a canonical path we should be symlink-free.

Join a path onto a canonical path, returning a CanonicalPathBuf.

Returns an iterator over the entries within a directory.

The iterator will yield instances of io::Result. New errors may be encountered after an iterator is initially constructed.

This is an alias to fs::read_dir.

Does this path exist?

Is this path a file?

Is this path a directory?

Trait Implementations

impl AsRef<CanonicalPath> for CanonicalPathBuf
[src]

Performs the conversion.

impl Borrow<CanonicalPath> for CanonicalPathBuf
[src]

Immutably borrows from an owned value. Read more

impl Debug for CanonicalPath
[src]

Formats the value using the given formatter. Read more

impl PartialOrd for CanonicalPath
[src]

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

impl Ord for CanonicalPath
[src]

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

impl PartialEq for CanonicalPath
[src]

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

This method tests for !=.

impl Eq for CanonicalPath
[src]

impl Hash for CanonicalPath
[src]

Feeds this value into the given [Hasher]. Read more

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

impl AsRef<Path> for CanonicalPath
[src]

Performs the conversion.

impl ToOwned for CanonicalPath
[src]

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

Auto Trait Implementations