Skip to main content

Store

Trait Store 

Source
pub trait Store: Send + Sync {
    // Required methods
    fn persist_with_upstreams(
        &self,
        key: &Key,
        bytes: &[u8],
        tool_kind: &str,
        file_roots: Vec<FileRootSerde>,
        upstream_keys: Vec<String>,
    ) -> Result<(), StoreError>;
    fn lookup(&self, key: &Key) -> Result<Option<Payload>, StoreError>;
    fn remove(&self, key: &Key) -> Result<(), StoreError>;
    fn total_bytes(&self) -> Result<u64, StoreError>;
    fn evict_to_cap(&self, cap_bytes: u64) -> Result<usize, StoreError>;
    fn iter_meta(&self) -> Result<Vec<(Key, PayloadMeta)>, StoreError>;
    fn contains(&self, key: &Key) -> bool;

    // Provided method
    fn persist(
        &self,
        key: &Key,
        bytes: &[u8],
        tool_kind: &str,
        file_roots: Vec<FileRootSerde>,
    ) -> Result<(), StoreError> { ... }
}
Expand description

Storage backend trait. Concrete impls: FileStore (local content-addressed disk), and (M4 step 7+) RemoteStore over HTTP. LiveCache owns one Box<dyn Store> and routes every content-addressed read/write through this trait so the same cache state machine works against either backend without conditional compilation in the runtime layer.

Required Methods§

Source

fn persist_with_upstreams( &self, key: &Key, bytes: &[u8], tool_kind: &str, file_roots: Vec<FileRootSerde>, upstream_keys: Vec<String>, ) -> Result<(), StoreError>

Source

fn lookup(&self, key: &Key) -> Result<Option<Payload>, StoreError>

Source

fn remove(&self, key: &Key) -> Result<(), StoreError>

Source

fn total_bytes(&self) -> Result<u64, StoreError>

Source

fn evict_to_cap(&self, cap_bytes: u64) -> Result<usize, StoreError>

Source

fn iter_meta(&self) -> Result<Vec<(Key, PayloadMeta)>, StoreError>

Source

fn contains(&self, key: &Key) -> bool

Provided Methods§

Source

fn persist( &self, key: &Key, bytes: &[u8], tool_kind: &str, file_roots: Vec<FileRootSerde>, ) -> Result<(), StoreError>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§