pub struct Store { /* private fields */ }
Expand description
A database for reading and writing objects to disk, one file per object.
Implementations
sourceimpl Store
impl Store
Object lookup
sourcepub fn contains(&self, id: impl AsRef<oid>) -> bool
pub fn contains(&self, id: impl AsRef<oid>) -> bool
Returns true if the given id is contained in our repository.
sourcepub fn lookup_prefix(
&self,
prefix: Prefix
) -> Result<Option<PrefixLookupResult>, Error>
pub fn lookup_prefix(
&self,
prefix: Prefix
) -> Result<Option<PrefixLookupResult>, Error>
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.
sourcepub fn try_find<'a>(
&self,
id: impl AsRef<oid>,
out: &'a mut Vec<u8>
) -> Result<Option<Data<'a>>, Error>
pub fn try_find<'a>(
&self,
id: impl AsRef<oid>,
out: &'a mut Vec<u8>
) -> Result<Option<Data<'a>>, Error>
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.
sourceimpl Store
impl Store
Iteration and traversal
sourcepub fn iter(&self) -> IterⓘNotable traits for Iterimpl Iterator for Iter type Item = Result<ObjectId, Error>;
pub fn iter(&self) -> IterⓘNotable traits for Iterimpl Iterator for Iter type Item = Result<ObjectId, Error>;
Return an iterator over all objects contained in the database.
The Id
s 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.
sourceimpl Store
impl Store
sourcepub fn verify_integrity(
&self,
progress: impl Progress,
should_interrupt: &AtomicBool
) -> Result<Statistics, Error>
pub fn verify_integrity(
&self,
progress: impl Progress,
should_interrupt: &AtomicBool
) -> Result<Statistics, Error>
Check all loose objects for their integrity checking their hash matches the actual data and by decoding them fully.
sourceimpl Store
impl Store
Initialization
sourcepub fn at(objects_directory: impl Into<PathBuf>, object_hash: Kind) -> Store
pub fn at(objects_directory: impl Into<PathBuf>, object_hash: Kind) -> Store
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.
sourcepub fn object_hash(&self) -> Kind
pub fn object_hash(&self) -> Kind
Return the kind of hash we would iterate and write.
Trait Implementations
sourceimpl Write for Store
impl Write for Store
sourcefn write_buf(&self, kind: Kind, from: &[u8]) -> Result<ObjectId, Self::Error>
fn write_buf(&self, kind: Kind, from: &[u8]) -> Result<ObjectId, Self::Error>
Write the given buffer in from
to disk in one syscall at best.
This will cost at least 4 IO operations.
impl Eq for Store
impl StructuralEq for Store
impl StructuralPartialEq for Store
Auto Trait Implementations
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnwindSafe for Store
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more