pub trait ChunkStore: Send {
// Required methods
fn put(&mut self, data: &[u8]) -> Result<ContentHash, StoreError>;
fn get(&self, hash: &ContentHash) -> Result<Vec<u8>, StoreError>;
fn has(&self, hash: &ContentHash) -> bool;
}Expand description
The chunk-store seam (D7). Conformance suite: tests/conformance.rs.
put is content-addressed and idempotent; get must return exactly the
bytes that hash to hash or an error, never silently wrong data.
Required Methods§
Sourcefn put(&mut self, data: &[u8]) -> Result<ContentHash, StoreError>
fn put(&mut self, data: &[u8]) -> Result<ContentHash, StoreError>
Stores data and returns its content address. Idempotent.
Sourcefn get(&self, hash: &ContentHash) -> Result<Vec<u8>, StoreError>
fn get(&self, hash: &ContentHash) -> Result<Vec<u8>, StoreError>
Retrieves the bytes for hash, verifying them against the address.
Sourcefn has(&self, hash: &ContentHash) -> bool
fn has(&self, hash: &ContentHash) -> bool
Whether hash is present.