Skip to main content

CasStore

Struct CasStore 

Source
pub struct CasStore { /* private fields */ }
Expand description

Content-addressable chunk store.

Implementations§

Source§

impl CasStore

Source

pub fn open(path: &Path) -> Result<Self>

Open or create a CAS store at {path}/.foxing_cas/.

Source

pub fn store_file( &self, rel_path: &str, data: &[u8], meta: &FileMeta, ) -> Result<CasStoreStats>

Store a file by chunking its data and writing unique chunks.

Source

pub fn delta_store_file( &self, rel_path: &str, data: &[u8], meta: &FileMeta, ) -> Result<DeltaStoreStats>

Store a file using chunk-level delta, writing only changed chunks.

Source

pub fn delete_file(&self, rel_path: &str) -> Result<()>

Record a file deletion in the manifest.

Source

pub fn rename_file(&self, from: &str, to: &str) -> Result<()>

Record a file rename in the manifest.

Source

pub fn snapshot(&self, name: &str) -> Result<()>

Record a snapshot marker in the manifest.

Source

pub fn read_file(&self, rel_path: &str) -> Result<Vec<u8>>

Reconstruct a file from its chunks.

Source

pub fn list_files(&self) -> Result<Vec<FileEntry>>

Replay manifest to get current file state.

Source

pub fn compact(&self) -> Result<CompactStats>

Compact the manifest and remove orphaned chunks.

Source

pub fn stats(&self) -> Result<(u64, u64, u64)>

Get store statistics.

Source

pub fn store_fxar_as_cas(&self, archive_name: &str, data: &[u8]) -> Result<()>

Store an FXAR archive as a CAS-chunked entity under a synthetic path.

Source

pub fn read_fxar_from_cas(&self, archive_name: &str) -> Result<Vec<u8>>

Read an FXAR archive back from CAS, reconstructing it byte-identically.

Source

pub fn has_fxar_in_cas(&self, archive_name: &str) -> Result<bool>

Check whether an FXAR archive exists in this CAS store.

Source

pub fn import_fxar<R: Read + Seek>(&self, reader: R) -> Result<CasStoreStats>

Import an FXAR v2 archive into this CAS store. Reads the archive, stores unique chunks, and creates manifest entries.

Source

pub fn export_fxar<W: Write + Seek>( &self, writer: W, compress: &str, ) -> Result<FxarExportStats>

Export this CAS store as an FXAR v2 archive.

Source

pub fn store_files_batch( &self, files: &[(String, &[u8], &FileMeta)], ) -> Result<BatchStats>

Store multiple files in a single batch with amortized fsync.

Reduces NFS COMMIT RPCs from 2N (per-chunk sync + per-chunk dir sync) to ~3 for an N-file batch by deferring all fsyncs to two bulk phases: Phase 1: write all chunks (tmp -> rename, no fsync) Phase 2: fsync each unique chunk shard directory (typically 1-3) Phase 3: append all manifest entries + single fsync

Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more