Skip to main content

EngineTransaction

Struct EngineTransaction 

Source
pub struct EngineTransaction<T: LinkReference, L: TransitionLogStore> { /* private fields */ }
Expand description

An isolated write set with the same raw LinksStorage API as other backends. Dropping or rolling back discards the write set; allocation may leave gaps.

Implementations§

Source§

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

Source

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

Remember the current write set. Savepoints nest.

Source

pub fn rollback_to_savepoint( &mut self, savepoint: Savepoint, ) -> Result<(), LinkError>

Discard writes made after this savepoint and every later savepoint. The savepoint itself stays usable, as in PostgreSQL and SQLite.

Source

pub fn release_savepoint( &mut self, savepoint: Savepoint, ) -> Result<(), LinkError>

Forget this savepoint and every later one, keeping all writes.

Source§

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

Source

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

Reads a link and reserves its address for this session, like SQL SELECT ... FOR UPDATE. Another session’s write or lock of the address is then refused (or waits, with lock_wait) until this session ends, so a read-modify-write cannot be overtaken. A missing address is reserved too, which keeps other sessions from creating it. Refused with busy while another session owns the address, and with conflict when the link changed after this session began. Needs pessimistic concurrency.

Source

pub fn write_owner(&self) -> Option<u64>

Identifies this session’s write ownership while it lasts. None unless the engine selected pessimistic concurrency.

Source

pub fn take_write_blocker(&mut self) -> Option<u64>

The owner that refused this session’s last write, once. Lets a caller that cannot block, such as JavaScript on one thread, wait and detect cycles itself.

Source

pub fn get_name(&self, id: T) -> Option<String>

Source

pub fn set_name(&mut self, id: T, name: Option<String>) -> Result<(), LinkError>

Source

pub fn get_by_name(&self, name: &str) -> Option<T>

Source

pub fn rollback(&mut self)

Source

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

Trait Implementations§

Source§

impl<T: LinkReference, L: TransitionLogStore> Drop for EngineTransaction<T, L>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl<T: LinkReference, L: TransitionLogStore> LinksStorage<T> for EngineTransaction<T, L>

Source§

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

Flush commits the staged transaction, rather than exposing uncommitted data.

Creates a link and returns its address. A uniqueness resolver may return an existing link after removing the temporary allocation.
Ensures a link exists at index, creating placeholders as needed.
Returns the link stored at index, if any.
Repoints index at source/target, returning the previous state.
Deletes index, returning the link that was removed.
Returns every link in the store.
Self::create_link, reporting every change, including partial changes before an error. Transactions need these callbacks to distinguish a new allocation from a duplicate resolved into an existing link. Read more
Self::ensure_link_created, reporting every placeholder it creates. Read more
Returns true when a link exists at index.
Writes exactly this row for undo and replay, returning the previous state. Read more
Self::update_link, reporting every (before, after) change it made. Read more
Self::delete_link, reporting every (before, after) change it made. Read more
Returns every link matching the (optional) index/source/target pattern.
Finds the address of a link with the given source and target.
Returns the address of an existing (source, target) link, creating it when it does not exist yet.
Number of links currently stored.
Source§

fn capture_names(&mut self) -> Result<Option<BTreeMap<T, String>>, LinkError>

Optional logical name snapshot for transactional undo. Unnamed stores return None without allocation. Include names of absent/external rows.
Changes one logical name without recording. A named adapter must restore external-reference names even when their row currently does not exist.
Source§

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

Cheap check for “did another process write to this database since we last read or wrote it?”. Read more
Source§

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

Re-reads the database from disk, discarding cached state. Read more
Source§

impl<T: QueryAddress, L: TransitionLogStore> NamedTypeLinks<T> for EngineTransaction<T, L>

Source§

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

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

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

Source§

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

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

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

Source§

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

Source§

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

Source§

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

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

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

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

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn remove_name(&mut self, id: T) -> 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 try_get_or_create(&mut self, source: T, target: T) -> Result<T>

Fallible pair lookup/allocation for composable query and decorator writes.
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, L> !Freeze for EngineTransaction<T, L>

§

impl<T, L> RefUnwindSafe for EngineTransaction<T, L>
where T: RefUnwindSafe,

§

impl<T, L> Send for EngineTransaction<T, L>
where L: Send,

§

impl<T, L> Sync for EngineTransaction<T, L>
where L: Send,

§

impl<T, L> Unpin for EngineTransaction<T, L>
where T: Unpin,

§

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

§

impl<T, L> UnwindSafe for EngineTransaction<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> 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.