pub struct Handle<S> where
    S: Deref<Target = Store> + Clone
{ pub refresh: RefreshMode, pub max_recursion_depth: usize, pub ignore_replacements: bool, /* private fields */ }
Expand description

This effectively acts like a handle but exists to be usable from the actual crate::Handle implementation which adds caches on top. Each store is quickly cloned and contains thread-local state for shared packs.

Fields

refresh: RefreshMode

Defines what happens when there is no more indices to load.

max_recursion_depth: usize

The maximum recursion depth for resolving ref-delta base objects, that is objects referring to other objects within a pack. Recursive loops are possible only in purposefully crafted packs. This value doesn’t have to be huge as in typical scenarios, these kind of objects are rare and chains supposedly are even more rare.

ignore_replacements: bool

If true, replacements will not be performed even if these are available.

Implementations

Return the exact number of packed objects after loading all currently available indices as last seen on disk.

Given a prefix candidate with an object id and an initial hex_len, check if it only matches a single object within the entire object database and increment its hex_len by one until it is unambiguous. Return Ok(None) if no object with that prefix exists.

Find the only object matching prefix and return it as Ok(Some(Ok(<ObjectId>))), or return Ok(Some(Err(())) if multiple different objects with the same prefix were found.

Return Ok(None) if no object matched the prefix.

Pass candidates to obtain the set of all object ids matching prefix, with the same return value as one would have received if it remained None.

Performance Note
  • Unless the handles refresh mode is set to Never, each lookup will trigger a refresh of the object databases files on disk if the prefix doesn’t lead to ambiguous results.
  • Since all objects need to be examined to assure non-amiguous return values, after calling this method all indices will be loaded.
  • If candidates is Some(…), the traversal will continue to obtain all candidates, which takes more time as there is no early abort.

Return an iterator over all objects, first the ones in all packs of all linked databases (via alternates), followed by all loose objects.

Call once if pack ids are stored and later used for lookup, meaning they should always remain mapped and not be unloaded even if they disappear from disk. This must be called if there is a chance that git maintenance is happening while a pack is created.

Return a shared reference to the contained store.

Return an owned store with shared ownership.

Set the handle to never cause ODB refreshes if an object could not be found.

The latter is the default, as typically all objects referenced in a git repository are contained in the local clone. More recently, however, this doesn’t always have to be the case due to sparse checkouts and other ways to only have a limited amount of objects available locally.

Return the current refresh mode.

Convert a ref counted store into one that is ref-counted and thread-safe, by creating a new Store.

Convert a ref counted store into one that is ref-counted and thread-safe, by creating a new Store

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Executes the destructor for this type. Read more

The error returned by try_find()

Returns true if the object exists in the database.

Like Find::try_find(), but with support for controlling the pack cache. A pack_cache can be used to speed up subsequent lookups, set it to crate::cache::Never if the workload isn’t suitable for caching. Read more

Find the packs location where an object with id can be found in the database, or None if there is no pack holding the object. Read more

Obtain a vector of all offsets, in index order, along with their object id.

Return the find::Entry for location if it is backed by a pack. Read more

Find an object matching id in the database while placing its raw, undecoded data into buffer. A pack_cache can be used to speed up subsequent lookups, set it to crate::cache::Never if the workload isn’t suitable for caching. Read more

The error returned by try_find()

Returns true if the object exists in the database.

Find an object matching id in the database while placing its raw, undecoded data into buffer. Read more

The error type used for all trait methods. Read more

As write, but takes an input stream. This is commonly used for writing blobs directly without reading them to memory first. Read more

Write objects using the intrinsic kind of hash into the database, returning id to reference it in subsequent reads. Read more

As write, but takes an object kind along with its encoded bytes.

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

Like try_find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error.

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired object type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type. Read more

Like find(…), but flattens the Result<Option<_>> into a single Result making a non-existing object an error while returning the desired iterator type. 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 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.