Skip to main content

ObjectStore

Trait ObjectStore 

Source
pub trait ObjectStore {
    // Required methods
    fn put(&mut self, bytes: &[u8]) -> Result<Id>;
    fn get(&self, id: &Id) -> Result<Vec<u8>>;
    fn get_range(&self, id: &Id, offset: u64, len: u64) -> Result<Vec<u8>>;

    // Provided methods
    fn contains(&self, id: &Id) -> Result<bool> { ... }
    fn list(&self) -> Result<Vec<(Id, u64)>> { ... }
    fn remove(&self, id: &Id) -> Result<u64> { ... }
}
Expand description

A content-addressed store keyed by BLAKE3-256 of the object bytes.

The object namespace is the descriptor’s object table: the raw, uncompressed bytes a DRA EMIT_OBJECT/DEFLATE_REPLAY op consumes. Inline and external objects share one id space, so equal bytes are equal ids regardless of which document they came from.

put takes &mut self (ids are content-derived, so retries are idempotent). list/remove support mark-and-sweep GC; both decline by default so a backend that exposes no enumeration or per-object delete (EntropyFS) fails closed rather than reporting a fake sweep.

Required Methods§

Source

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

Store bytes, returning its content id.

Idempotent and at-least-once: identical bytes always return the same id and are stored once; a retry after a crash is a no-op. A returned id guarantees the bytes are durable under ObjectStore::get.

Source

fn get(&self, id: &Id) -> Result<Vec<u8>>

Fetch the exact bytes for id.

MUST verify BLAKE3(bytes) == id before returning.

Source

fn get_range(&self, id: &Id, offset: u64, len: u64) -> Result<Vec<u8>>

Fetch len bytes of id starting at offset.

STRICT: a request for offset + len > stored_len(id) is a typed error, never a silent EOF clip. Range reads carry no whole-object hash gate.

Provided Methods§

Source

fn contains(&self, id: &Id) -> Result<bool>

Whether id is present. EmbeddedStore overrides it with a stat.

Source

fn list(&self) -> Result<Vec<(Id, u64)>>

Every stored (id, raw_len), for closure checking and GC.

The default declines, so a backend without enumeration never reports a fake closure.

Source

fn remove(&self, id: &Id) -> Result<u64>

Delete id, returning the raw bytes reclaimed (0 if absent).

The default declines: a backend that exposes no per-object delete must not appear to have swept anything.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§