pub struct Store { /* private fields */ }
Expand description

A database for reading and writing objects to disk, one file per object.

Implementations

Object lookup

Returns true if the given id is contained in our repository.

Given a prefix, find an object that matches it uniquely within this loose object database as Ok(Some(Ok(<oid>))). If there is more than one object matching the object Ok(Some(Err(())) is returned.

Finally, if no object matches, the return value is Ok(None).

The outer Result is to indicate errors during file system traversal.

Return the object identified by the given ObjectId if present in this database, writing its raw data into the given out buffer.

Returns Err if there was an error locating or reading the object. Returns Ok<None> if there was no such object.

Iteration and traversal

Return an iterator over all objects contained in the database.

The Ids returned by the iterator can typically be used in the locate(…) method. Note that the result is not sorted or stable, thus ordering can change between runs.

Notes

loose::Iter is used instead of impl Iterator<…> to allow using this iterator in struct fields, as is currently needed if iterators need to be implemented by hand in the absence of generators.

Check all loose objects for their integrity checking their hash matches the actual data and by decoding them fully.

Initialization

Initialize the Db with the objects_directory containing the hexadecimal first byte subdirectories, which in turn contain all loose objects.

In a git repository, this would be .git/objects.

The object_hash determines which hash to use when writing, finding or iterating objects.

Return the path to our objects directory.

Return the kind of hash we would iterate and write.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

This method tests for !=.

Write the given buffer in from to disk in one syscall at best.

This will cost at least 4 IO operations.

Write the given stream in from to disk with at least one syscall.

This will cost at least 4 IO operations.

The error type used for all trait methods. Read more

Write objects using the intrinsic kind of hash into the database, returning id to reference it in subsequent reads. 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

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.