pub struct CasStore { /* private fields */ }Expand description
Filesystem-backed content-addressed store.
Storage layout (identical to the cas-serve binary):
xorbs/default.{xorb_hash}— raw xorb bytes (concatenated chunks).shards/{file_hash}— reconstruction shard (.mdbbinary).
Implementations§
Source§impl CasStore
impl CasStore
Sourcepub fn exists(&self, hash: &str) -> bool
pub fn exists(&self, hash: &str) -> bool
True if the store can serve this content address (shard or raw blob).
Sourcepub async fn get_file_bytes(&self, hash: &str) -> Result<Vec<u8>, StoreError>
pub async fn get_file_bytes(&self, hash: &str) -> Result<Vec<u8>, StoreError>
Reassemble a file from its reconstruction shard (or raw-blob fallback) and
return the original bytes. This is the in-process equivalent of the
binary’s GetFile handler.
Sourcepub async fn put_file_bytes(&self, data: &[u8]) -> Result<PutResult, StoreError>
pub async fn put_file_bytes(&self, data: &[u8]) -> Result<PutResult, StoreError>
Ingest raw bytes: chunk (Gearhash CDC), aggregate into xorbs, build the
reconstruction shard, and store both content-addressed. The XET merkle
root is computed HERE from the actual bytes and returned in
PutResult::merkle — the caller never supplies it. Existing xorbs are
skipped (global content-addressed dedup), so PutResult::bytes_stored
counts only newly-written xorb payload.
This is the in-process, library form of the binary’s UploadFile
handler; both go through this single implementation.
Sourcepub async fn read_xorb(
&self,
xorb_hash_hex: &str,
) -> Result<Vec<u8>, StoreError>
pub async fn read_xorb( &self, xorb_hash_hex: &str, ) -> Result<Vec<u8>, StoreError>
Read the raw bytes of a single stored xorb, keyed by its hex xorb hash.
Unlike CasStore::get_file_bytes this does NOT reconstruct a file: it
returns the exact on-disk xorbs/default.{hash} payload. This backs the
HuggingFace-XET GET /get_xorb/{hash}/ wire route, which fetches an
individual xorb (not a reconstructed file). Callers wanting a byte
sub-range should slice the returned buffer (the store keeps whole xorbs).