Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction<'db> { /* private fields */ }
Expand description

Explicit transaction over the in-memory graph.

The implementation is conservative: read-only transactions hold a database read lock, and read-write transactions hold the database write lock. Read-write transactions lazily create a cloned staging graph on the first mutating statement, then either swap that graph into place on commit or drop it on rollback. Explicit mutating statements capture a graph + WAL-buffer savepoint so a failed or dropped streaming statement only rolls back its own effects, not the transaction as a whole.

When a WAL is attached, mutation events fire into a tx-local buffer rather than the durable log. The buffer is replayed into the WAL exactly once at commit, so recovery never observes partial / aborted / dropped statements.

Implementations§

Source§

impl<'db> Transaction<'db>

Source

pub fn mode(&self) -> TransactionMode

Transaction mode chosen at begin time.

Source

pub fn execute( &mut self, query: &str, options: Option<ExecuteOptions>, ) -> Result<QueryResult>

Execute a query inside the transaction and return a materialized QueryResult.

Source

pub fn execute_with_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, timeout: Duration, ) -> Result<QueryResult>

Execute a query inside the transaction with a cooperative deadline.

Source

pub fn execute_with_params( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, ) -> Result<QueryResult>

Execute a parameterised query inside the transaction.

Source

pub fn execute_with_params_timeout( &mut self, query: &str, options: Option<ExecuteOptions>, params: BTreeMap<String, LoraValue>, timeout: Duration, ) -> Result<QueryResult>

Execute a parameterised query inside the transaction with a cooperative deadline.

Source

pub fn execute_rows(&mut self, query: &str) -> Result<Vec<Row>>

Execute a query inside the transaction and return hydrated rows before final result-format projection.

Source

pub fn execute_rows_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<Vec<Row>>

Execute a parameterised query inside the transaction and return hydrated rows before final result-format projection.

Source

pub fn stream(&mut self, query: &str) -> Result<QueryStream<'static>>

Execute a query inside the transaction and return an owning row stream.

Source

pub fn stream_with_params( &mut self, query: &str, params: BTreeMap<String, LoraValue>, ) -> Result<QueryStream<'static>>

Execute a parameterised query inside the transaction and return an owning row stream.

Source

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

Commit the transaction and publish staged changes.

When WAL is attached the buffered tx-local mutation log is replayed into the durable WAL as a single committed transaction; recovery therefore observes either every write in this transaction or none.

Source

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

Roll back the transaction. Staged graph changes and buffered mutations are discarded; the WAL is never armed.

Trait Implementations§

Source§

impl Drop for Transaction<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'db> Freeze for Transaction<'db>

§

impl<'db> !RefUnwindSafe for Transaction<'db>

§

impl<'db> !Send for Transaction<'db>

§

impl<'db> Sync for Transaction<'db>

§

impl<'db> Unpin for Transaction<'db>

§

impl<'db> UnsafeUnpin for Transaction<'db>

§

impl<'db> !UnwindSafe for Transaction<'db>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more