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
impl CatalogStore
Sourcepub fn delta_since(&self, from_epoch: u64) -> Result<CatalogDelta>
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.
Sourcepub fn apply_delta(&mut self, delta: CatalogDelta) -> Result<()>
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
impl CatalogStore
Sourcepub fn replay(replay: CatalogReplay) -> Result<Self>
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
impl CatalogStore
Sourcepub fn from_snapshot(snapshot: CatalogSnapshot) -> Result<Self>
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
impl CatalogStore
Sourcepub fn install_table(&mut self, spec: CatalogTableSpec) -> Result<()>
pub fn install_table(&mut self, spec: CatalogTableSpec) -> Result<()>
Installs a table spec, erroring if a table of that name already exists.
Sourcepub fn table(&self, name: &Symbol) -> Option<&CatalogTableSpec>
pub fn table(&self, name: &Symbol) -> Option<&CatalogTableSpec>
Returns the spec for name, if the table is installed.
Sourcepub fn tables(&self) -> &BTreeMap<Symbol, CatalogTableSpec>
pub fn tables(&self) -> &BTreeMap<Symbol, CatalogTableSpec>
Returns all installed table specs by name.
Sourcepub fn row(&self, table: &Symbol, key: &Symbol) -> Option<&CatalogRow>
pub fn row(&self, table: &Symbol, key: &Symbol) -> Option<&CatalogRow>
Returns the row at table/key, reading through any active overlay.
Sourcepub fn rows(&self, table: &Symbol) -> Option<&BTreeMap<Symbol, CatalogRow>>
pub fn rows(&self, table: &Symbol) -> Option<&BTreeMap<Symbol, CatalogRow>>
Returns all rows of table by key, reading through any active overlay.
Sourcepub fn sequence(&self, name: &Symbol) -> Option<u64>
pub fn sequence(&self, name: &Symbol) -> Option<u64>
Returns the current value of sequence name, if any.
Sourcepub fn journal(&self) -> &[CatalogEvent]
pub fn journal(&self) -> &[CatalogEvent]
Returns the append-only audit journal, reading through any active overlay.
Sourcepub fn epoch(&self) -> u64
pub fn epoch(&self) -> u64
Returns the current catalog epoch, reading through any active overlay.
Sourcepub fn with_overlay<F, R>(&mut self, f: F) -> Result<R>
pub fn with_overlay<F, R>(&mut self, f: F) -> 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
impl Clone for CatalogStore
Source§fn clone(&self) -> CatalogStore
fn clone(&self) -> CatalogStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more