Skip to main content

Store

Trait Store 

Source
pub trait Store:
    Send
    + Sync
    + Debug {
    // Required methods
    fn put<'life0, 'life1, 'async_trait>(
        &'life0 self,
        bytes: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<Digest, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        digest: &'life1 Digest,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Where raw output is kept so that nothing is lost by slicing.

§Why this is declared here

ARCHITECTURE.md §5 lists Store among the nine extension points, and feature 10 will own the durable implementation — the journal references payloads by CAS digest (US-1005) and so does a large condensate payload (US-0104). None of that exists yet, and US-0701 needs exactly one thing from it: somewhere to put the original before the copy is cut down.

So the boundary is declared here, as narrowly as it can be, exactly as the runtime declares LedgerSink for the log it does not own. Feature 10’s store will satisfy it unchanged.

Required Methods§

Source

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

Write bytes, returning their content address.

Idempotent by construction: the address is the content, so storing the same bytes twice is storing them once.

§Errors

StoreError if the bytes could not be written. The caller must treat that as the slice not having happened — a condensate whose raw points at nothing is worse than no condensate, because it claims an original that cannot be produced.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, digest: &'life1 Digest, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read bytes back by address.

§Errors

StoreError if the bytes are not there or could not be read.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§