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§
sourcefn clone_blob(&mut self, hash: &BlobHash) -> Result<(), NoSuchBlobError>
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);
sourcefn insert_blob(&mut self, bytes: &[u8]) -> BlobHash
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.
sourcefn retrieve_blob(&self, hash: &BlobHash) -> Result<&[u8], NoSuchBlobError>
fn retrieve_blob(&self, hash: &BlobHash) -> Result<&[u8], NoSuchBlobError>
Returns the bytes stored at the content address hash
.