Struct fclones::path::Path[][src]

pub struct Path { /* fields omitted */ }
Expand description

Memory-efficient file path representation.

When storing multiple paths with common parent, the standard std::path::PathBuf would keep the parent path text duplicated in memory, wasting a lot of memory. This structure here shares the common parent between many paths by reference-counted references.

Implementations

Moves this Path under an Arc. You need to wrap Path before joining anything to it.

Copies this path from under an Arc. Generally cheap, because only the last component is copied.

Creates an owned Path with path adjoined to self. The path must be relative.

Returns the name of the last component of this path or None if the path is directory (e.g. root dir or parent dir).

Returns the name of the last component of this path or None if the path is directory (e.g. root dir or parent dir). Doesn’t allocate anything on the heap.

Returns the parent directory of this path. Doesn’t allocate anything on the heap.

Returns a path that joined to base would give this path. If base is the same as this path, returns current directory. If this path doesn’t have a base prefix, returns None.

Returns true if self is a prefix of another path

Converts this path to a standard library path buffer. We need this to be able to use this path with other standard library I/O functions.

Converts this path to an UTF encoded string. Any non-Unicode sequences are replaced with [U+FFFD REPLACEMENT CHARACTER][U+FFFD].

Returns a hash of the full path. Useful for deduplicating paths without making path clones. We need 128-bits so that collisions are not a problem. Thanks to using a long hash we can be sure collisions won’t be a problem.

Returns the number of components in this path

Returns the first component of this path

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.

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

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 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

Serialize this value into the given Serde serializer. Read more

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 alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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.