Skip to main content

ChunkCache

Trait ChunkCache 

Source
pub trait ChunkCache: Send + Sync {
    // Required methods
    fn get(&self, addr: &str) -> Option<Bytes>;
    fn put(&self, addr: &str, body: &[u8]);
    fn remove(&self, addr: &str);
    fn retain(&self, live: &HashSet<String>);
}
Expand description

Chunk bodies by content address. Every method is best effort: a cache that cannot read or write costs requests, never correctness, so nothing here returns an error.

Required Methods§

Source

fn get(&self, addr: &str) -> Option<Bytes>

The body kept under addr, if any. NOT verified here: the loader hashes every body once, whichever way it arrived.

Source

fn put(&self, addr: &str, body: &[u8])

Keep body under addr. The caller has verified it.

Source

fn remove(&self, addr: &str)

Drop addr (it failed verification).

Source

fn retain(&self, live: &HashSet<String>)

Keep only these addresses.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§