Skip to main content

TransactionsDecorator

Struct TransactionsDecorator 

Source
pub struct TransactionsDecorator { /* private fields */ }
Expand description

The transactions decorator wraps a NamedTypesDecorator and records every write as a reversible Transition in log_store.

Implementations§

Source§

impl TransactionsDecorator

Source

pub fn new( inner: NamedTypesDecorator, log_store: NamedTypesDecorator, retention_policy: LogRetentionPolicy, commit_mode: CommitMode, trace: bool, ) -> Result<Self>

Creates a new transactions decorator wrapping inner, using log_store as the sidecar log store.

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

Returns a snapshot of the transitions log in sequence order.

Source

pub fn inner(&self) -> &NamedTypesDecorator

Source

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

Source

pub fn log_store(&self) -> &NamedTypesDecorator

Source

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

Source

pub fn into_inner(self) -> (NamedTypesDecorator, NamedTypesDecorator)

Source

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

Source

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

Source

pub fn update(&mut self, id: u32, source: u32, target: u32) -> Result<Link>

Source

pub fn delete(&mut self, id: u32) -> Result<Link>

Source

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

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: u32) -> bool

Source

pub fn get(&self, id: u32) -> Option<&Link>

Source

pub fn all(&self) -> Vec<&Link>

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn apply_transition(&mut self, transition: &Transition)

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: &Transition)

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

Rebuilds the in-memory log and marker tables from the sidecar log store and re-applies committed-but-unapplied side-effects.

Trait Implementations§

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(&mut self, id: u32, source: u32, target: u32) -> Result<Link>

Source§

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

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 try_ensure_created(&mut self, id: u32) -> Result<u32>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Auto Trait Implementations§

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

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.