gix_odb::loose

Struct Store

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

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

Implementations§

source§

impl Store

Object lookup

source

pub fn contains(&self, id: &oid) -> bool

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

source

pub fn lookup_prefix( &self, prefix: Prefix, candidates: Option<&mut HashSet<ObjectId>>, ) -> Result<Option<Outcome>, 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.

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.

source

pub fn try_find<'a>( &self, id: &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.

source

pub fn try_header(&self, id: &oid) -> Result<Option<(u64, Kind)>, Error>

Return only the decompressed size of the object and its kind without fully reading it into memory as tuple of (size, kind). Returns None if id does not exist in the database.

source§

impl Store

Iteration and traversal

source

pub fn iter(&self) -> Iter

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.

source§

impl Store

source

pub fn verify_integrity( &self, progress: &mut dyn DynNestedProgress, 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.

source§

impl Store

Access

source

pub fn object_path(&self, id: &oid) -> PathBuf

Return the path to the object with id.

Note that is may not exist yet.

source§

impl Store

Initialization

source

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.

source

pub fn path(&self) -> &Path

Return the path to our objects directory.

source

pub fn object_hash(&self) -> Kind

Return the kind of hash we would iterate and write.

Trait Implementations§

source§

impl Clone for Store

source§

fn clone(&self) -> Store

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl PartialEq for Store

source§

fn eq(&self, other: &Store) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Write for Store

source§

fn write_buf(&self, kind: Kind, from: &[u8]) -> Result<ObjectId, Error>

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

This will cost at least 4 IO operations.

source§

fn write_stream( &self, kind: Kind, size: u64, from: &mut dyn Read, ) -> Result<ObjectId, Error>

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

This will cost at least 4 IO operations.

source§

fn write(&self, object: &dyn WriteTo) -> Result<ObjectId, Error>

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

impl Eq for Store

source§

impl StructuralPartialEq for Store

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.