Trait spacetimedb_table::blob_store::BlobStore

source ·
pub trait BlobStore {
    // Required methods
    fn clone_blob(&mut self, hash: &BlobHash) -> Result<(), NoSuchBlobError>;
    fn insert_blob(&mut self, bytes: &[u8]) -> BlobHash;
    fn retrieve_blob(&self, hash: &BlobHash) -> Result<&[u8], NoSuchBlobError>;
    fn free_blob(&mut self, hash: &BlobHash) -> Result<(), NoSuchBlobError>;
}
Expand description

The interface that tables use to talk to the blob store engine for large var-len objects.

These blob objects are referred to by their BlobHash, which is currently defined through BLAKE3 on the bytes of the blob object.

Required Methods§

source

fn clone_blob(&mut self, hash: &BlobHash) -> Result<(), NoSuchBlobError>

Mark the hash as used.

This is a more efficient way of doing:

let bytes = self.retrieve_blob(&hash);
let _ = self.insert_blob(&bytes);
source

fn insert_blob(&mut self, bytes: &[u8]) -> BlobHash

Insert bytes into the blob store.

Returns the content address of bytes a BlobHash which can be used in [retrieve_blob] to fetch it.

source

fn retrieve_blob(&self, hash: &BlobHash) -> Result<&[u8], NoSuchBlobError>

Returns the bytes stored at the content address hash.

source

fn free_blob(&mut self, hash: &BlobHash) -> Result<(), NoSuchBlobError>

Marks the hash as unused.

Depending on the strategy employed by the blob store, this might not actually free the data, but rather just decrement a reference count.

Implementors§