Skip to main content

Engine

Struct Engine 

Source
pub struct Engine<T, L> { /* private fields */ }
Expand description

Share clones of this handle across threads. All writes must use its sessions; opening multiple independent writers on the same log is not supported.

Implementations§

Source§

impl<T: LinkReference, P: TransitionLogStore> Engine<T, P>

Source

pub fn fork<L: TransitionLogStore>( &self, log: L, options: EngineOptions, ) -> Result<Branch<T, P, L>, LinkError>

Seed an empty independent log with a flushed copy of the current state. Branch addresses are independent; divergent allocation collisions conflict.

Source

pub fn resume_branch<L: TransitionLogStore>( &self, log: L, options: EngineOptions, merge_base_record: &str, ) -> Result<Branch<T, P, L>, LinkError>

Restore a branch using a merge-base record saved by its previous owner. The caller must associate that descriptor with the same logical parent. A descriptor must identify a real committed revision of the branch log.

Source§

impl<T: LinkReference, L: TransitionLogStore> Engine<T, L>

Source

pub fn export_checkpoint(&self) -> Result<Vec<String>, LinkError>

Export retained committed snapshots without rewriting the live log. The caller owns atomic publication and synchronization of these records.

Source

pub fn export_checkpoint_at( &self, revision: u64, ) -> Result<Vec<String>, LinkError>

Export the retained snapshots up to one retained revision, as a journal whose reopened head is that revision.

Source

pub fn backup_to<D: TransitionLogStore>( &self, destination: &mut D, revision: Option<u64>, ) -> Result<u64, LinkError>

Copy a consistent cut to an empty log while commits continue, and return the revision it ends at. None selects the current revision; a retained earlier revision gives a point-in-time copy.

The commit mutex is held only while the cut is encoded, never during destination I/O, so a slow or failing destination cannot delay or fence this engine. After a failure the destination may hold a shorter copy, so discard it. See docs/ENGINE-BACKUP.md.

Source

pub fn backup_incremental_to<D: TransitionLogStore>( &self, destination: &mut D, ) -> Result<u64, LinkError>

Bring an earlier backup of this engine up to the current revision by appending only the revisions it lacks, each as the rows that changed, and return the revision it now ends at. An empty destination gets a full copy.

The destination’s last revision must still be retained here and hold the same rows, otherwise it is refused and left alone: take a full backup. The commit mutex is held only to select the snapshots. After a failure the destination may end at an earlier revision, and calling again continues from there. See docs/ENGINE-BACKUP.md.

Source§

impl<T: LinkReference, L: ReplaceableTransitionLogStore> Engine<T, L>

Source

pub fn compact_journal(&self) -> Result<bool, LinkError>

Atomically replace the journal while holding the commit mutex. Identical records return false. Any replacement error fences this owner until reopen. Unsupported capability leaves the engine available for ordinary commits.

Source

pub fn compact_journal_after(&self, commits: u64) -> Result<bool, LinkError>

Compact once at least commits revisions have landed since the last compaction by this owner, and otherwise do nothing and return false. A log that cannot be replaced is refused either way, so a wrong selection shows at once. The first call after opening counts from revision 0, which also compacts a journal left long by an earlier owner. See docs/ENGINE-CHECKPOINTS.md.

Source§

impl<T: LinkReference, L: TransitionLogStore> Engine<T, L>

Source

pub fn commit_group( &self, sessions: Vec<EngineTransaction<T, L>>, ) -> Result<Vec<GroupCommitOutcome>, LinkError>

Consume independent sessions and share one flush across accepted writes. Validation follows input order and retains the configured isolation rules. Each write session retains its own revision; this is not an atomic batch. An uncertain append/flush fences the engine and retains its old visible state. All provisionally accepted members then return Indeterminate, including read-only members that may depend on a tentative revision.

Foreign sessions cause an outer error before I/O; consumed sessions are rolled back on that path. A log that syncs on every append still performs those syncs; select buffered append with durable flush to amortize them. Private preparation retains history/map metadata and selected logical revision records until publication. Ordinary commits keep their own path.

Source§

impl<T: LinkReference, L: TransitionLogStore> Engine<T, L>

Source

pub fn open(log: L, options: EngineOptions) -> Result<Self, LinkError>

Source

pub fn snapshot(&self) -> Result<Snapshot<T>, LinkError>

Source

pub fn snapshot_at(&self, revision: u64) -> Result<Snapshot<T>, LinkError>

Source

pub fn begin(&self) -> Result<EngineTransaction<T, L>, LinkError>

Source

pub fn with_log<R>( &self, operation: impl FnOnce(&mut L) -> Result<R, LinkError>, ) -> Result<R, LinkError>

Run a caller’s replication/catch-up/diagnostics operation under the same mutex as commits. An error poisons the engine because its outcome may be unknown.

Source

pub fn into_log(self) -> Result<L, Self>

Extract the authoritative log once every other handle/session is dropped.

Trait Implementations§

Source§

impl<T, L> Clone for Engine<T, L>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T, L> Freeze for Engine<T, L>

§

impl<T, L> RefUnwindSafe for Engine<T, L>

§

impl<T, L> Send for Engine<T, L>
where L: Send, T: Send + Sync,

§

impl<T, L> Sync for Engine<T, L>
where L: Send, T: Send + Sync,

§

impl<T, L> Unpin for Engine<T, L>

§

impl<T, L> UnsafeUnpin for Engine<T, L>

§

impl<T, L> UnwindSafe for Engine<T, L>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.