Skip to main content

BlobStore

Trait BlobStore 

Source
pub trait BlobStore: Send + Sync {
    // Required methods
    fn put_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        content: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<ContentHash>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 ContentHash,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_blobs<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<BlobEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 ContentHash,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn has_blob<'life0, 'life1, 'async_trait>(
        &'life0 self,
        hash: &'life1 ContentHash,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

A content-addressed blob store for out-of-line record bodies (Body::Blob). Content is keyed by its ContentHash, so byte-identical bodies — e.g. code-graph slices shared across worktrees (ADR 0012) — are stored once. Writes are write-if-absent: storing content that already exists is an idempotent no-op, never a conflict (same hash ⇒ same bytes).

Required Methods§

Source

fn put_blob<'life0, 'life1, 'async_trait>( &'life0 self, content: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<ContentHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store content addressed by its hash, write-if-absent, and return the hash. Idempotent: storing identical content again is a no-op.

Source

fn get_blob<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 ContentHash, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch blob content by hash, or None if absent.

Source

fn list_blobs<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<BlobEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Every stored blob with the time it was last written. Order is unspecified, and a hash may repeat — a caller that cares resolves a duplicate to its newest timestamp. Used by GC to enumerate candidates and decide which are old enough to sweep (ADR 0024, 0028).

Source

fn delete_blob<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 ContentHash, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete the blob addressed by hash. Deleting an absent blob is an idempotent no-op — GC may race another sweeper or a re-put.

Provided Methods§

Source

fn has_blob<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 ContentHash, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Whether hash is stored.

Defaulted so this is not a breaking addition. The default fetches the blob and throws the bytes away; substrates override it with a cheap existence check. A writer uses this after committing to confirm the blobs it referenced are still present (ADR 0028).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§