pub struct BlobStore { /* private fields */ }Expand description
Filesystem-backed immutable content-addressed blob storage.
Blobs are written to a temporary file in their final shard, synchronized, and then atomically renamed. Every read re-hashes the bytes before returning them.
Implementations§
Source§impl BlobStore
impl BlobStore
Sourcepub fn open(data_dir: impl AsRef<Path>) -> Result<Self, BlobStoreError>
pub fn open(data_dir: impl AsRef<Path>) -> Result<Self, BlobStoreError>
Open or create a blob store below data_dir.
§Errors
Returns BlobStoreError::Io if the store directory cannot be created.
Sourcepub fn open_in(data_directory: &DataDirectory) -> Result<Self, BlobStoreError>
pub fn open_in(data_directory: &DataDirectory) -> Result<Self, BlobStoreError>
Open or create a blob store below a pinned data-directory capability.
§Errors
Returns BlobStoreError::Io if the real blobs directory cannot be
created, pinned, or synchronized.
Sourcepub fn put(&self, bytes: &[u8]) -> Result<BlobId, BlobStoreError>
pub fn put(&self, bytes: &[u8]) -> Result<BlobId, BlobStoreError>
Store bytes exactly once and return their BLAKE3 identity.
§Errors
Returns an error for I/O failures or if an existing blob fails hash verification.
Sourcepub fn get(&self, id: BlobId) -> Result<Vec<u8>, BlobStoreError>
pub fn get(&self, id: BlobId) -> Result<Vec<u8>, BlobStoreError>
Load and hash-verify one immutable blob.
§Errors
Returns an I/O error when the blob is unavailable and BlobStoreError::Corrupt
when its bytes no longer match the requested identity.
Sourcepub fn get_bounded(
&self,
id: BlobId,
maximum: usize,
) -> Result<Vec<u8>, BlobStoreError>
pub fn get_bounded( &self, id: BlobId, maximum: usize, ) -> Result<Vec<u8>, BlobStoreError>
Load and hash-verify one immutable blob without allocating beyond maximum.
§Errors
Returns BlobStoreError::SizeLimit before reading when metadata already
exceeds the bound, or if a concurrently enlarged file crosses it while read.