pub struct LooseStore { /* private fields */ }Expand description
On-disk loose object store for one objects/ directory.
Implementations§
Source§impl LooseStore
impl LooseStore
Sourcepub fn new(
objects_dir: PathBuf,
hash_algo: HashAlgo,
compression: Compression,
) -> Self
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.
Sourcepub fn objects_dir(&self) -> &Path
pub fn objects_dir(&self) -> &Path
Path to the objects/ root.
Sourcepub fn object_path(&self, oid: &ObjectId) -> PathBuf
pub fn object_path(&self, oid: &ObjectId) -> PathBuf
Filesystem path for a loose object file.
Sourcepub fn ensure_all_loose_prefix_dirs(&self) -> Result<()>
pub fn ensure_all_loose_prefix_dirs(&self) -> Result<()>
Sourcepub fn zlib_compress_store_bytes(&self, store_bytes: &[u8]) -> Result<Vec<u8>>
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.
Sourcepub fn write_store_prehashed(
&self,
oid: &ObjectId,
store_bytes: &[u8],
options: WriteOptions,
) -> Result<ObjectId>
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.
Sourcepub fn write_zlib_prehashed(
&self,
oid: &ObjectId,
zlib_store: &[u8],
options: WriteOptions,
) -> Result<ObjectId>
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.
Sourcepub fn read_verify_oid(path: &Path, expected_oid: &ObjectId) -> Result<Object>
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
Error::Zlib— decompression failed.Error::CorruptObject— header is malformed.Error::LooseHashMismatch— payload OID does not matchexpected_oid.
Trait Implementations§
Source§impl Clone for LooseStore
impl Clone for LooseStore
Source§impl Debug for LooseStore
impl Debug for LooseStore
Source§impl ObjectStore for LooseStore
impl ObjectStore for LooseStore
Source§fn read(&self, oid: &ObjectId) -> Result<Option<Object>>
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>>
fn read_into( &self, oid: &ObjectId, buf: &mut Vec<u8>, ) -> Result<Option<ObjectKind>>
Load object payload into
buf, reusing its capacity when possible. Read moreSource§fn read_info(&self, oid: &ObjectId) -> Result<Option<ObjectInfo>>
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<'_>>>
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<()>
fn for_each_object( &self, f: &mut dyn FnMut(&ObjectId) -> ControlFlow<()>, ) -> Result<()>
Source§fn lookup_prefix(
&self,
prefix: &str,
limit: usize,
out: &mut Vec<ObjectId>,
) -> Result<()>
fn lookup_prefix( &self, prefix: &str, limit: usize, out: &mut Vec<ObjectId>, ) -> Result<()>
Source§fn contains(&self, oid: &ObjectId) -> Result<bool>
fn contains(&self, oid: &ObjectId) -> Result<bool>
Whether
oid is stored in this backend (without reading the payload). Read moreSource§impl WritableObjectStore for LooseStore
impl WritableObjectStore for LooseStore
Source§fn write(
&self,
kind: ObjectKind,
data: &[u8],
options: WriteOptions,
) -> Result<ObjectId>
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>
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
Auto Trait Implementations§
impl Freeze for LooseStore
impl RefUnwindSafe for LooseStore
impl Send for LooseStore
impl Sync for LooseStore
impl Unpin for LooseStore
impl UnsafeUnpin for LooseStore
impl UnwindSafe for LooseStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more