Skip to main content

BlobStore

Trait BlobStore 

Source
pub trait BlobStore: Send + Sync {
    // Required methods
    fn put<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        value: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_range<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        range: Range<u64>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prefix: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn put_chunks<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        chunks: Vec<Bytes>,
    ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_range_exact<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _key: &'life1 str,
        _range: Range<u64>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn compare_and_swap<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        expected: Option<Bytes>,
        new_value: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<CasOutcome, ObjectLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn take_media_op_stats(&self) -> Option<MediaOpStats> { ... }
}
Expand description

A minimal async object store over immutable, string-keyed blobs.

This is the storage port the log engine is built on. Implement it for your backend (e.g. S3) to store the log there. Data objects are written once under a unique key. Partition index objects use compare_and_swap.

Durability: put is durable-on-return for crash-durable adapters (LocalBlobStore, an S3 adapter) — once it resolves Ok, the bytes survive a crash, so a caller may treat Ok as a durability barrier. MemoryBlobStore is a test/dev backend and is not crash-durable.

Required Methods§

Source

fn put<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, value: Bytes, ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Durably store value at key (see the trait-level durability note). value may be arbitrarily large; a network adapter should chunk it (e.g. S3 multipart) rather than rely on a single request.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetch the whole object at key, or None if absent.

Source

fn get_range<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, range: Range<u64>, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a byte sub-range of an object without fetching the whole thing. None if the key is absent. range.end > len or range.start > range.end is ObjectLogError::RangeOutOfBounds; an empty n..n returns Ok(Some(<empty>)). No integrity check is performed — payloads are opaque.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, prefix: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List keys beginning with prefix.

Source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an object; deleting a missing key is a no-op success.

Provided Methods§

Source

fn put_chunks<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, chunks: Vec<Bytes>, ) -> Pin<Box<dyn Future<Output = Result<(), ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Durably store a logical object assembled from immutable byte chunks.

The default implementation concatenates chunks and delegates to put. Object-store adapters can override this to stream or multipart-upload chunks without materializing the full object twice.

Source

fn get_range_exact<'life0, 'life1, 'async_trait>( &'life0 self, _key: &'life1 str, _range: Range<u64>, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>, ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Strict physical range allocation contract. Caller pre-admits requested bytes. Must never fetch a whole object or buffer more than this range. Bounds accumulated payload; transport chunks/headers require extra scratch. Local blocking reads can outlive cancellation: the operation owner must retain admission until physical completion. Unknown adapters fail closed; legacy get_range remains compatible.

Source

fn compare_and_swap<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, expected: Option<Bytes>, new_value: Bytes, ) -> Pin<Box<dyn Future<Output = Result<CasOutcome, ObjectLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Replace key only when its current bytes equal expected.

expected == None succeeds only when the key is absent (create-only). The default reads and then puts, which is not atomic across processes. MemoryBlobStore, LocalBlobStore, and the S3 adapter override it with a real conditional update.

Source

fn take_media_op_stats(&self) -> Option<MediaOpStats>

Snapshot and reset media-op counters since the previous take.

Adapters that can count exact durable units (fsyncs, S3 PUTs) should implement this. The default returns None; the engine then treats each successful put / put_chunks as one media op (documented fallback).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§