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

Source

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.

Source

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>

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 sidecar filename for the transitions log.

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

Source

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.

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<T, S, L> UnwindSafe for GenericTransactionsDecorator<T, S, L>
where S: UnwindSafe, L: UnwindSafe, Vec<GenericTransition<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, 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, <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.