Skip to main content

FsBlobStore

Struct FsBlobStore 

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

On-disk content-addressed store, sharded by digest prefix.

Layout (rooted at <root>/blobs/sha256/):

blobs/sha256/
  ab/
    ab12cd34…ff.zst        (zstd-19 compressed payload)
  cd/
    cd56ef78…00.zst

The two-byte shard prefix keeps directory entry counts <65 536 even at large stores. Atomic write is temp file in same dir → fsync → rename.

Thread-safe (concurrent put/get ok). On a race two writers may both produce the same temp file path — we add a per-process counter to dodge.

Implementations§

Source§

impl FsBlobStore

Source

pub fn open(root: impl AsRef<Path>) -> Result<Self>

Open (or create) an on-disk store rooted at root.

Creates root/blobs/sha256/ if missing. Idempotent.

Source

pub fn root(&self) -> &Path

The root directory passed to Self::open.

Trait Implementations§

Source§

impl BlobStore for FsBlobStore

Source§

fn put(&self, bytes: &[u8]) -> Result<Digest256>

Insert bytes, return its content digest. Idempotent: storing the same payload twice produces the same digest and is a no-op the second time.
Source§

fn get(&self, digest: &Digest256) -> Result<Vec<u8>>

Retrieve the bytes for a previously-stored digest.
Source§

fn contains(&self, digest: &Digest256) -> Result<bool>

Cheap existence check.
Source§

fn physical_bytes(&self) -> Result<u64>

Total physical bytes stored on disk (compressed). Implementations may approximate; used for pf status and the storage-efficiency microbenchmark.
Source§

impl Debug for FsBlobStore

Source§

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

Formats the value using the given formatter. 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> 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, 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.