pub struct GenericTransactionsDecorator<T, S, L>{ /* private fields */ }Expand description
The transactions decorator wraps any LinksStorage and records
every write as a reversible GenericTransition in log_store.
Implementations§
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Sourcepub fn apply_transition(&mut self, transition: &GenericTransition<T>)
pub fn apply_transition(&mut self, transition: &GenericTransition<T>)
Public helper for higher-level decorators (e.g. version control) — applies a single transition without writing a new log entry.
Sourcepub fn revert_transition(&mut self, transition: &GenericTransition<T>)
pub fn revert_transition(&mut self, transition: &GenericTransition<T>)
Public helper for higher-level decorators (e.g. version control) — reverts a single transition without writing a new log entry.
Sourcepub fn recover(&mut self) -> Result<(), LinkError>
pub fn recover(&mut self) -> Result<(), LinkError>
Rebuilds the in-memory log and marker tables from the sidecar log store and re-applies committed-but-unapplied side-effects.
Entries that cannot be parsed are skipped: an append-only log
can end in the partial entry of a crashed write, and the
links-backed log can hold names that belong to other features.
An entry whose addresses do not fit into T is not skipped —
that means the log was written by a wider address type and
silently dropping it would corrupt the recovered state.
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Sourcepub fn new(
inner: S,
log_store: L,
retention_policy: LogRetentionPolicy,
commit_mode: CommitMode,
trace: bool,
) -> Result<Self, LinkError>
pub fn new( inner: S, log_store: L, retention_policy: LogRetentionPolicy, commit_mode: CommitMode, trace: bool, ) -> Result<Self, LinkError>
Creates a new transactions decorator wrapping inner, using
log_store as the sidecar log. Runs crash recovery before
returning.
Sourcepub fn make_transitions_database_filename<P: AsRef<Path>>(
database_filename: P,
) -> PathBuf
pub fn make_transitions_database_filename<P: AsRef<Path>>( database_filename: P, ) -> PathBuf
Conventional sidecar filename for the transitions log.
pub fn retention_policy(&self) -> &LogRetentionPolicy
pub fn set_retention_policy(&mut self, policy: LogRetentionPolicy)
pub fn commit_mode(&self) -> CommitMode
pub fn set_commit_mode(&mut self, mode: CommitMode)
pub fn applied_sequence(&self) -> i64
pub fn last_logged_sequence(&self) -> i64
Sourcepub fn log(&self) -> Vec<GenericTransition<T>>
pub fn log(&self) -> Vec<GenericTransition<T>>
Returns a snapshot of the transitions log in sequence order.
pub fn inner(&self) -> &S
pub fn inner_mut(&mut self) -> &mut S
pub fn log_store(&self) -> &L
pub fn log_store_mut(&mut self) -> &mut L
pub fn into_inner(self) -> (S, L)
Sourcepub fn flush(&mut self) -> Result<(), LinkError>
pub fn flush(&mut self) -> Result<(), LinkError>
Makes both the data store and the transitions log durable.
Sourcepub fn save(&mut self) -> Result<(), LinkError>
pub fn save(&mut self) -> Result<(), LinkError>
Alias of flush, kept for parity with the other
decorators and with the C# API.
Sourcepub fn has_external_changes(&self) -> Result<bool, LinkError>
pub fn has_external_changes(&self) -> Result<bool, LinkError>
Cheap check for “has another process written to the wrapped store since we last read or wrote it?”.
Sourcepub fn reload(&mut self) -> Result<(), LinkError>
pub fn reload(&mut self) -> Result<(), LinkError>
Re-reads the wrapped store and rebuilds the transactions state from the log — the recovery path after another process wrote.
pub fn create(&mut self, source: T, target: T) -> Result<T, LinkError>
pub fn update( &mut self, id: T, source: T, target: T, ) -> Result<GenericLink<T>, LinkError>
pub fn delete(&mut self, id: T) -> Result<GenericLink<T>, LinkError>
Sourcepub fn delete_observed(
&mut self,
id: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<GenericLink<T>, LinkError>
pub fn delete_observed( &mut self, id: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<GenericLink<T>, LinkError>
Self::delete, reporting every change the underlying store made.
Deleting a link cascades into every link that still used it, and those
deletions are changes of their own: the C# CLI hands
AdvancedMixedQueryProcessor.RemoveLinks a handler that links.Delete
calls once per removed link, so --changes lists the usages too. The
observer is the same seam, threaded through the decorator stack.
Sourcepub fn create_and_update(
&mut self,
source: T,
target: T,
) -> Result<T, LinkError>
pub fn create_and_update( &mut self, source: T, target: T, ) -> Result<T, LinkError>
Composite create-and-update used by callers that want a link
initialised with source/target in a single pair of transitions
(matches the C# CreateAndUpdate extension semantics, which
always emits a Create followed by an Update transition).
pub fn exists(&self, id: T) -> bool
pub fn search(&self, source: T, target: T) -> Option<T>
pub fn get_or_create(&mut self, source: T, target: T) -> Result<T, LinkError>
pub fn ensure_created(&mut self, id: T) -> Result<T, LinkError>
pub fn begin_transaction(&mut self) -> Result<TransactionHandle, LinkError>
pub fn commit(&mut self) -> Result<(), LinkError>
pub fn rollback(&mut self) -> Result<(), LinkError>
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Read paths that lend out references, available whenever the wrapped
store keeps its links resident in memory.
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Read paths that lend out references, available whenever the wrapped store keeps its links resident in memory.