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 journal_entry_count(&self) -> usize
pub fn journal_entry_count(&self) -> usize
Number of entries the durable journal currently holds.
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
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>,
) -> Result<(), LinkError>
pub fn apply_transition( &mut self, transition: &GenericTransition<T>, ) -> Result<(), LinkError>
Public helper for higher-level decorators (e.g. version control) — applies a single transition without writing a new log entry. Rejects replay while a transaction or its cleanup still owns the data.
Sourcepub fn revert_transition(
&mut self,
transition: &GenericTransition<T>,
) -> Result<(), LinkError>
pub fn revert_transition( &mut self, transition: &GenericTransition<T>, ) -> Result<(), LinkError>
Reverts one transition, reporting storage errors to the caller. Rejects replay while a transaction or its cleanup still owns the data.
Sourcepub fn apply_record(
&mut self,
record: &JournalRecord<T>,
) -> Result<(), LinkError>
pub fn apply_record( &mut self, record: &JournalRecord<T>, ) -> Result<(), LinkError>
Replays a complete record, including names, without logging another write.
Sourcepub fn revert_record(
&mut self,
record: &JournalRecord<T>,
) -> Result<(), LinkError>
pub fn revert_record( &mut self, record: &JournalRecord<T>, ) -> Result<(), LinkError>
Undoes a complete record, including names, without logging another write.
Sourcepub fn recover(&mut self) -> Result<(), LinkError>
pub fn recover(&mut self) -> Result<(), LinkError>
Validates the sidecar journal before rebuilding history and replaying it. Unrelated names are ignored; malformed or contradictory transaction records fail before rows or live indexes change. Identical retries are collapsed. A failure retains write admission until recovery succeeds.
Source§impl<T, S, L> GenericTransactionsDecorator<T, S, L>
impl<T, S, L> GenericTransactionsDecorator<T, S, L>
Sourcepub fn with_row_undo(self, policy: RowUndoPolicy) -> Result<Self, LinkError>
pub fn with_row_undo(self, policy: RowUndoPolicy) -> Result<Self, LinkError>
Select row undo while idle. Recovery always understands mandatory images, even if subsequent owners use the default observation policy.
Sourcepub fn set_row_undo_policy(
&mut self,
policy: RowUndoPolicy,
) -> Result<(), LinkError>
pub fn set_row_undo_policy( &mut self, policy: RowUndoPolicy, ) -> Result<(), LinkError>
Change policy while idle, preserving the caller’s owner on rejection.
pub fn row_undo_policy(&self) -> RowUndoPolicy
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 filename of the links-backed transitions log
(<stem>.transitions.links). clink now keeps its journal in
make_transitions_log_filename and imports this store once.
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.
Sourcepub fn journal(&self) -> Vec<JournalRecord<T>>
pub fn journal(&self) -> Vec<JournalRecord<T>>
Complete retained records, including optional name payloads.
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>
Sourcepub fn update_observed(
&mut self,
id: T,
source: T,
target: T,
observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>),
) -> Result<GenericLink<T>, LinkError>
pub fn update_observed( &mut self, id: T, source: T, target: T, observer: &mut dyn FnMut(GenericLink<T>, GenericLink<T>), ) -> Result<GenericLink<T>, LinkError>
Self::update, reporting every change the underlying store made.
An update that would duplicate an existing doublet is resolved into a
merge that deletes the updated link, so one call can report several
changes, exactly like C#’s links.Update(restriction, substitution, handler).
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>
Source§impl GenericTransactionsDecorator<u32, NamedTypesDecorator, FileTransitionLog>
impl GenericTransactionsDecorator<u32, NamedTypesDecorator, FileTransitionLog>
Sourcepub fn defer_batch_checkpoint(&mut self)
pub fn defer_batch_checkpoint(&mut self)
Defer file writes requested within a CLI batch to its final checkpoint. The named store keeps edits in memory and the commit still syncs the journal before saving data and again after writing the applied markers.
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.
pub fn get(&self, id: T) -> Option<&GenericLink<T>>
pub fn all(&self) -> Vec<&GenericLink<T>>
pub fn query( &self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<&GenericLink<T>>
Trait Implementations§
Source§impl<L: TransitionLogStore> NamedTypeLinks for GenericTransactionsDecorator<u32, NamedTypesDecorator, L>
impl<L: TransitionLogStore> NamedTypeLinks for GenericTransactionsDecorator<u32, NamedTypesDecorator, L>
Source§fn reserve_query_allocations(
&mut self,
processor: &QueryProcessor,
restriction: &LinoLink,
substitution: &LinoLink,
) -> Result<Option<HashSet<u32>>>
fn reserve_query_allocations( &mut self, processor: &QueryProcessor, restriction: &LinoLink, substitution: &LinoLink, ) -> Result<Option<HashSet<u32>>>
Source§fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>
fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>
Source§fn try_create(&mut self, source: u32, target: u32) -> Result<u32>
fn try_create(&mut self, source: u32, target: u32) -> Result<u32>
fn try_ensure_created(&mut self, id: u32) -> Result<u32>
fn create(&mut self, source: u32, target: u32) -> u32
fn ensure_created(&mut self, id: u32) -> u32
fn get_link(&mut self, id: u32) -> Option<Link>
fn exists(&mut self, id: u32) -> bool
Source§fn update_observed(
&mut self,
id: u32,
source: u32,
target: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
fn update_observed( &mut self, id: u32, source: u32, target: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
Self::update, reporting every change the update caused. Read moreSource§fn delete_observed(
&mut self,
id: u32,
observer: ChangeObserver<'_>,
) -> Result<Link>
fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>
Self::delete, reporting every change the deletion caused. Read morefn all_links(&mut self) -> Vec<Link>
fn search(&mut self, source: u32, target: u32) -> Option<u32>
fn get_or_create(&mut self, source: u32, target: u32) -> u32
fn get_name(&mut self, id: u32) -> Result<Option<String>>
fn set_name(&mut self, id: u32, name: &str) -> Result<u32>
fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>
fn remove_name(&mut self, id: u32) -> Result<()>
fn save(&mut self) -> Result<()>
Source§fn query_limits(&self) -> Option<QueryLimits>
fn query_limits(&self) -> Option<QueryLimits>
Source§fn reference_exists(&mut self, id: T) -> bool
fn reference_exists(&mut self, id: T) -> bool
id names a link that exists. Read moreSource§fn claims(&mut self, id: T) -> Option<bool>
fn claims(&mut self, id: T) -> Option<bool>
id is an address of this store, so a link created there
(Self::ensure_created, the undo of a delete) belongs in it; None
for a plain store, which has no addresses of its own. Read moreSource§fn next_created_addresses(&mut self, count: usize) -> Result<Vec<T>>
fn next_created_addresses(&mut self, count: usize) -> Result<Vec<T>>
count links created in the store get. Read morefn update(&mut self, id: T, source: T, target: T) -> Result<GenericLink<T>>
fn delete(&mut self, id: T) -> Result<GenericLink<T>>
Source§fn query_links(
&mut self,
index: Option<T>,
source: Option<T>,
target: Option<T>,
) -> Vec<GenericLink<T>>
fn query_links( &mut self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<GenericLink<T>>
None matches any value, in
the order of their addresses. Read more