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§
Sourcefn put(&mut self, bytes: &[u8]) -> Result<Id>
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.
Sourcefn get(&self, id: &Id) -> Result<Vec<u8>>
fn get(&self, id: &Id) -> Result<Vec<u8>>
Fetch the exact bytes for id.
MUST verify BLAKE3(bytes) == id before returning.
- absent id ->
crate::ErrorClass::MissingExternalObject - bytes hash != id ->
crate::ErrorClass::IntegrityMismatch
Provided Methods§
Sourcefn contains(&self, id: &Id) -> Result<bool>
fn contains(&self, id: &Id) -> Result<bool>
Whether id is present. EmbeddedStore overrides it with a stat.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".