pub struct Cache<'paths> { /* private fields */ }
Expand description

A cache for efficiently executing operations on directories and files which are encountered in sorted order. That way, these operations can be re-used for subsequent invocations in the same directory.

This cache can be configured to create directories efficiently, read git-ignore files and git-attribute files, in any combination.

A cache for directory creation to reduce the amount of stat calls when creating directories safely, that is without following symlinks that might be on the way.

As a special case, it offers a ‘prefix’ which (by itself) is assumed to exist and may contain symlinks. Everything past that prefix boundary must not contain a symlink. We do this by allowing any input path.

Another added benefit is its ability to store the path of full path of the entry to which leading directories are to be created to avoid allocating memory.

For this to work, it remembers the last ‘good’ path to a directory and assumes that all components of it are still valid, too. As directories are created, the cache will be adjusted to reflect the latest seen directory.

The caching is only useful if consecutive calls to create a directory are using a sorted list of entries.

Implementations

Available on debug-assertions enabled only.
Available on debug-assertions enabled only.
Available on debug-assertions enabled only.
Available on debug-assertions enabled only.

Create a new instance with worktree_root being the base for all future paths we handle, assuming it to be valid which includes symbolic links to be included in it as well. The case configures attribute and exclusion query case sensitivity.

Append the relative path to the root directory the cache contains and efficiently create leading directories unless is_dir is known (Some(…)) then relative points to a directory itself in which case the entire resulting path is created as directory. If it’s not known it is assumed to be a file.

Provide access to cached information for that relative entry via the platform returned.

source

pub fn at_entry<'r, Find, E>(
    &mut self,
    relative: impl Into<&'r BStr>,
    is_dir: Option<bool>,
    find: Find
) -> Result<Platform<'_, 'paths>, Error>where
    Find: for<'a> FnMut(&oid, &'a mut Vec<u8, Global>) -> Result<BlobRef<'a>, E>,
    E: 'static + Error + Send + Sync,

Panics on illformed UTF8 in relative

Return the base path against which all entries or paths should be relative to when querying.

Note that this path may not be canonicalized.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. 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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. 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.