Skip to main content

LooseStore

Struct LooseStore 

Source
pub struct LooseStore { /* private fields */ }
Expand description

On-disk loose object store for one objects/ directory.

Implementations§

Source§

impl LooseStore

Source

pub fn new( objects_dir: PathBuf, hash_algo: HashAlgo, compression: Compression, ) -> Self

Open a loose store at objects_dir using hash_algo and zlib compression.

Source

pub fn objects_dir(&self) -> &Path

Path to the objects/ root.

Source

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

Filesystem path for a loose object file.

Source

pub fn ensure_all_loose_prefix_dirs(&self) -> Result<()>

Create all 256 loose-object prefix directories (objects/xx/).

§Errors

Returns Error::Io if a directory cannot be created.

Source

pub fn zlib_compress_store_bytes(&self, store_bytes: &[u8]) -> Result<Vec<u8>>

Zlib-compress canonical store bytes at this store’s compression level.

§Errors

Returns Error::Zlib when compression fails.

Source

pub fn write_store_prehashed( &self, oid: &ObjectId, store_bytes: &[u8], options: WriteOptions, ) -> Result<ObjectId>

Write canonical store bytes for a precomputed oid (hashing skipped).

§Errors

Same as WritableObjectStore::write.

Source

pub fn write_zlib_prehashed( &self, oid: &ObjectId, zlib_store: &[u8], options: WriteOptions, ) -> Result<ObjectId>

Write zlib-compressed store bytes for a precomputed oid.

§Errors

Same as WritableObjectStore::write.

Source

pub fn read_verify_oid(path: &Path, expected_oid: &ObjectId) -> Result<Object>

Read a loose object at path, verifying the payload hashes to expected_oid.

§Errors

Trait Implementations§

Source§

impl Clone for LooseStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LooseStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ObjectStore for LooseStore

Source§

fn hash_algo(&self) -> HashAlgo

Hash algorithm for objects written through this store.
Source§

fn read(&self, oid: &ObjectId) -> Result<Option<Object>>

Load the full object, if present. Read more
Source§

fn read_into( &self, oid: &ObjectId, buf: &mut Vec<u8>, ) -> Result<Option<ObjectKind>>

Load object payload into buf, reusing its capacity when possible. Read more
Source§

fn read_info(&self, oid: &ObjectId) -> Result<Option<ObjectInfo>>

Object kind and size without loading the full payload. Read more
Source§

fn open_stream(&self, oid: &ObjectId) -> Result<Option<ObjectStream<'_>>>

Open a stream over the object’s uncompressed payload. Read more
Source§

fn for_each_object( &self, f: &mut dyn FnMut(&ObjectId) -> ControlFlow<()>, ) -> Result<()>

Invoke f for every object id in this store until f returns ControlFlow::Break. Read more
Source§

fn lookup_prefix( &self, prefix: &str, limit: usize, out: &mut Vec<ObjectId>, ) -> Result<()>

Fill out with object ids whose hex form starts with prefix (case-insensitive). Read more
Source§

fn contains(&self, oid: &ObjectId) -> Result<bool>

Whether oid is stored in this backend (without reading the payload). Read more
Source§

fn contains_many(&self, oids: &[ObjectId]) -> Result<Vec<bool>>

For each id in oids, whether it is stored in this backend; the result has one entry per input id, in input order. Read more
Source§

fn refresh(&self) -> Result<bool>

Reload indexes or caches after on-disk changes (packs, alternates, MIDX). Read more
Source§

impl WritableObjectStore for LooseStore

Source§

fn write( &self, kind: ObjectKind, data: &[u8], options: WriteOptions, ) -> Result<ObjectId>

Store canonical object bytes and return the object id. Read more
Source§

fn write_stream( &self, kind: ObjectKind, size: u64, reader: &mut dyn Read, options: WriteOptions, ) -> Result<ObjectId>

Store an object from a byte stream of known uncompressed size. Read more
Source§

fn freshen(&self, oid: &ObjectId) -> Result<bool>

Mark oid as recently used so retention policies keep it (Git freshen). Read more

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.