Skip to main content

CasStore

Struct CasStore 

Source
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 (.mdb binary).

Implementations§

Source§

impl CasStore

Source

pub fn new(storage_path: impl AsRef<Path>) -> Self

Open a store rooted at storage_path.

Source

pub fn from_env() -> Self

Open a store using the standard env/default path resolution.

Source

pub fn exists(&self, hash: &str) -> bool

True if the store can serve this content address (shard or raw blob).

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for CasStore

Source§

fn clone(&self) -> CasStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CasStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V