Skip to main content

GenericTransactionsDecorator

Struct GenericTransactionsDecorator 

Source
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>

Source

pub fn journal_entry_count(&self) -> usize

Number of entries the durable journal currently holds.

Source§

impl<T, S, L> GenericTransactionsDecorator<T, S, L>

Source

pub fn set_name(&mut self, index: T, name: &str) -> Result<T, LinkError>

Source

pub fn remove_name(&mut self, index: T) -> Result<(), LinkError>

Source§

impl<T, S, L> GenericTransactionsDecorator<T, S, L>

Source

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.

Source

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.

Source

pub fn apply_record( &mut self, record: &JournalRecord<T>, ) -> Result<(), LinkError>

Replays a complete record, including names, without logging another write.

Source

pub fn revert_record( &mut self, record: &JournalRecord<T>, ) -> Result<(), LinkError>

Undoes a complete record, including names, without logging another write.

Source

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>

Source

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.

Source

pub fn set_row_undo_policy( &mut self, policy: RowUndoPolicy, ) -> Result<(), LinkError>

Change policy while idle, preserving the caller’s owner on rejection.

Source

pub fn row_undo_policy(&self) -> RowUndoPolicy

Source§

impl<T, S, L> GenericTransactionsDecorator<T, S, L>

Source

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.

Source

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.

Source

pub fn retention_policy(&self) -> &LogRetentionPolicy

Source

pub fn set_retention_policy(&mut self, policy: LogRetentionPolicy)

Source

pub fn commit_mode(&self) -> CommitMode

Source

pub fn set_commit_mode(&mut self, mode: CommitMode)

Source

pub fn applied_sequence(&self) -> i64

Source

pub fn last_logged_sequence(&self) -> i64

Source

pub fn log(&self) -> Vec<GenericTransition<T>>

Returns a snapshot of the transitions log in sequence order.

Source

pub fn journal(&self) -> Vec<JournalRecord<T>>

Complete retained records, including optional name payloads.

Source

pub fn inner(&self) -> &S

Source

pub fn inner_mut(&mut self) -> &mut S

Source

pub fn log_store(&self) -> &L

Source

pub fn log_store_mut(&mut self) -> &mut L

Source

pub fn into_inner(self) -> (S, L)

Source

pub fn flush(&mut self) -> Result<(), LinkError>

Makes both the data store and the transitions log durable.

Source

pub fn save(&mut self) -> Result<(), LinkError>

Alias of flush, kept for parity with the other decorators and with the C# API.

Source

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?”.

Source

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.

Source

pub fn create(&mut self, source: T, target: T) -> Result<T, LinkError>

Source

pub fn update( &mut self, id: T, source: T, target: T, ) -> Result<GenericLink<T>, LinkError>

Source

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).

Source

pub fn delete(&mut self, id: T) -> Result<GenericLink<T>, LinkError>

Source

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.

Source

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).

Source

pub fn exists(&self, id: T) -> bool

Source

pub fn search(&self, source: T, target: T) -> Option<T>

Source

pub fn get_or_create(&mut self, source: T, target: T) -> Result<T, LinkError>

Source

pub fn ensure_created(&mut self, id: T) -> Result<T, LinkError>

Source

pub fn begin_transaction(&mut self) -> Result<TransactionHandle, LinkError>

Source

pub fn commit(&mut self) -> Result<(), LinkError>

Finish the transaction. An append/flush error can have an unknown outcome: retry commit, rollback or save to finish the attempted decision. Further writes remain fenced until that work succeeds.

Source

pub fn rollback(&mut self) -> Result<(), LinkError>

Undo an open transaction, or finish its attempted commit if a previous commit failed with a possibly durable decision.

Source§

impl GenericTransactionsDecorator<u32, NamedTypesDecorator, FileTransitionLog>

Source

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.

Source

pub fn get(&self, id: T) -> Option<&GenericLink<T>>

Source

pub fn all(&self) -> Vec<&GenericLink<T>>

Source

pub fn query( &self, index: Option<T>, source: Option<T>, target: Option<T>, ) -> Vec<&GenericLink<T>>

Trait Implementations§

Source§

fn reserve_query_allocations( &mut self, processor: &QueryProcessor, restriction: &LinoLink, substitution: &LinoLink, ) -> Result<Option<HashSet<u32>>>

Reserve the actual allocation sequence without staging observable rows. Backends with a recycling allocator may retain the legacy probe path.
Source§

fn try_get_or_create(&mut self, source: u32, target: u32) -> Result<u32>

Fallible pair lookup/allocation for composable query and decorator writes.
Source§

fn try_create(&mut self, source: u32, target: u32) -> Result<u32>

Fallible allocation for backends that can report transaction/address errors.
Source§

fn try_ensure_created(&mut self, id: u32) -> Result<u32>

Source§

fn create(&mut self, source: u32, target: u32) -> u32

Source§

fn ensure_created(&mut self, id: u32) -> u32

Source§

fn exists(&mut self, id: u32) -> bool

Source§

fn update_observed( &mut self, id: u32, source: u32, target: u32, observer: ChangeObserver<'_>, ) -> Result<Link>

Self::update, reporting every change the update caused. Read more
Source§

fn delete_observed( &mut self, id: u32, observer: ChangeObserver<'_>, ) -> Result<Link>

Self::delete, reporting every change the deletion caused. Read more
Source§

fn search(&mut self, source: u32, target: u32) -> Option<u32>

Source§

fn get_or_create(&mut self, source: u32, target: u32) -> u32

Source§

fn get_name(&mut self, id: u32) -> Result<Option<String>>

Source§

fn set_name(&mut self, id: u32, name: &str) -> Result<u32>

Source§

fn get_by_name(&mut self, name: &str) -> Result<Option<u32>>

Source§

fn remove_name(&mut self, id: u32) -> Result<()>

Source§

fn save(&mut self) -> Result<()>

Source§

fn query_limits(&self) -> Option<QueryLimits>

A checked transport may restrict numeric input and query expansion.
Source§

fn reference_exists(&mut self, id: T) -> bool

Whether a reference of a query to id names a link that exists. Read more
Source§

fn claims(&mut self, id: T) -> Option<bool>

Whether 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 more
Source§

fn next_created_addresses(&mut self, count: usize) -> Result<Vec<T>>

The addresses the next count links created in the store get. Read more
Source§

fn update(&mut self, id: T, source: T, target: T) -> Result<GenericLink<T>>

Source§

fn delete(&mut self, id: T) -> Result<GenericLink<T>>

The links that match a pattern, where None matches any value, in the order of their addresses. Read more
Source§

fn get_or_create_named(&mut self, name: &str) -> Result<T>

Source§

fn format_reference(&mut self, id: T) -> Result<String>

Source§

fn format_lino(&mut self, link: &GenericLink<T>) -> Result<String>

Source§

fn lino_lines(&mut self) -> Result<Vec<String>>

Source§

fn write_lino_output<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
where Self: Sized,

Source§

fn print_all_lino(&mut self) -> Result<()>

Source§

fn print_change_lino( &mut self, before: &Option<GenericLink<T>>, after: &Option<GenericLink<T>>, ) -> Result<()>

Source§

fn format_structure(&mut self, id: T) -> Result<String>

Source§

fn format_structure_recursive( &mut self, id: T, visited: &mut HashSet<T>, ) -> Result<String>

Auto Trait Implementations§

§

impl<T, S, L> Forget for GenericTransactionsDecorator<T, S, L>

§

impl<T, S, L> Freeze for GenericTransactionsDecorator<T, S, L>
where S: Freeze, L: Freeze, Vec<JournalRecord<T>>: Freeze, Option<PendingTransaction<T>>: Freeze,

§

impl<T, S, L> Move for GenericTransactionsDecorator<T, S, L>

§

impl<T, S, L> RefUnwindSafe for GenericTransactionsDecorator<T, S, L>
where S: RefUnwindSafe, L: RefUnwindSafe, Vec<JournalRecord<T>>: RefUnwindSafe, Option<PendingTransaction<T>>: RefUnwindSafe,

§

impl<T, S, L> Send for GenericTransactionsDecorator<T, S, L>
where L: Send, S: Send, Vec<JournalRecord<T>>: Send, Option<PendingTransaction<T>>: Send,

§

impl<T, S, L> Sync for GenericTransactionsDecorator<T, S, L>
where L: Sync, S: Sync, Vec<JournalRecord<T>>: Sync, Option<PendingTransaction<T>>: Sync,

§

impl<T, S, L> Unpin for GenericTransactionsDecorator<T, S, L>
where L: Unpin, S: Unpin, Vec<JournalRecord<T>>: Unpin, Option<PendingTransaction<T>>: Unpin,

§

impl<T, S, L> UnsafeUnpin for GenericTransactionsDecorator<T, S, L>
where S: UnsafeUnpin, L: UnsafeUnpin, Vec<JournalRecord<T>>: UnsafeUnpin, Option<PendingTransaction<T>>: UnsafeUnpin,

§

impl<T, S, L> UnwindSafe for GenericTransactionsDecorator<T, S, L>
where S: UnwindSafe, L: UnwindSafe, Vec<JournalRecord<T>>: UnwindSafe, Option<PendingTransaction<T>>: UnwindSafe,

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.

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.