Skip to main content

CatalogStore

Struct CatalogStore 

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

Cx-free, lock-free transactional table storage owned by the registry.

The store holds table specs, rows by table and key, named sequences, the append-only journal, and the current epoch. It is the authoritative catalog storage described in the README section “Contract: registry catalog substrate”; mutation flows through CatalogTx commits, optionally buffered through an overlay.

§Examples

let mut store = CatalogStore::new();
let table = Symbol::new("registry/libs");
store.install_table(CatalogTableSpec::new(table.clone(), CatalogWritePolicy::Mutable)).unwrap();

let mut tx = CatalogTx::new();
tx.put_row(CatalogRow::new(table.clone(), Symbol::new("demo")));
let epoch = tx.commit(&mut store).unwrap();

assert_eq!(store.epoch(), epoch);
assert!(store.row(&table, &Symbol::new("demo")).is_some());

Implementations§

Source§

impl CatalogStore

Source

pub fn delta_since(&self, from_epoch: u64) -> Result<CatalogDelta>

Computes the delta carrying this store from from_epoch to its current epoch; from_epoch == 0 yields a full delta.

Source

pub fn apply_delta(&mut self, delta: CatalogDelta) -> Result<()>

Applies delta atomically after validating source epoch, table compatibility, sealed-row conflicts, change epochs, and target epoch; the store is left unchanged on error.

Source§

impl CatalogStore

Source

pub fn replay(replay: CatalogReplay) -> Result<Self>

Rebuilds a store by replaying replay’s events in order, validating each event epoch against the replay epoch.

Source§

impl CatalogStore

Source

pub fn from_snapshot(snapshot: CatalogSnapshot) -> Result<Self>

Restores a data-only store from snapshot, validating table keys, row keys, required fields, and row epochs.

Source§

impl CatalogStore

Source

pub fn new() -> Self

Creates an empty store with no tables, rows, or sequences.

Source

pub fn install_table(&mut self, spec: CatalogTableSpec) -> Result<()>

Installs a table spec, erroring if a table of that name already exists.

Source

pub fn table(&self, name: &Symbol) -> Option<&CatalogTableSpec>

Returns the spec for name, if the table is installed.

Source

pub fn tables(&self) -> &BTreeMap<Symbol, CatalogTableSpec>

Returns all installed table specs by name.

Source

pub fn row(&self, table: &Symbol, key: &Symbol) -> Option<&CatalogRow>

Returns the row at table/key, reading through any active overlay.

Source

pub fn rows(&self, table: &Symbol) -> Option<&BTreeMap<Symbol, CatalogRow>>

Returns all rows of table by key, reading through any active overlay.

Source

pub fn sequence(&self, name: &Symbol) -> Option<u64>

Returns the current value of sequence name, if any.

Source

pub fn journal(&self) -> &[CatalogEvent]

Returns the append-only audit journal, reading through any active overlay.

Source

pub fn epoch(&self) -> u64

Returns the current catalog epoch, reading through any active overlay.

Source

pub fn with_overlay<F, R>(&mut self, f: F) -> Result<R>
where F: FnOnce(&mut Self) -> Result<R>,

Runs f against a buffered overlay, committing its edits on success and rolling them back on error.

Trait Implementations§

Source§

impl Clone for CatalogStore

Source§

fn clone(&self) -> CatalogStore

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 CatalogStore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for CatalogStore

Source§

fn default() -> CatalogStore

Returns the “default value” for a type. 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.