pub struct RuntimeSession<P>{ /* private fields */ }Expand description
A session for executing operations with optional transaction support.
This is a high-level wrapper around the transaction machinery that provides a clean API for users. Operations can be executed directly or within a transaction.
Implementations§
Source§impl<P> RuntimeSession<P>
impl<P> RuntimeSession<P>
Sourcepub fn begin_transaction(&self) -> Result<RuntimeStatementResult<P>>
pub fn begin_transaction(&self) -> Result<RuntimeStatementResult<P>>
Begin a transaction in this session. Creates an isolated staging context automatically.
Sourcepub fn abort_transaction(&self)
pub fn abort_transaction(&self)
Mark the current transaction as aborted due to an error. This should be called when any error occurs during a transaction.
Sourcepub fn has_active_transaction(&self) -> bool
pub fn has_active_transaction(&self) -> bool
Check if this session has an active transaction.
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Check if the current transaction has been aborted due to an error.
Sourcepub fn commit_transaction(&self) -> Result<RuntimeStatementResult<P>>
pub fn commit_transaction(&self) -> Result<RuntimeStatementResult<P>>
Commit the current transaction and apply changes to the base context. If the transaction was aborted, this acts as a ROLLBACK instead.
Sourcepub fn rollback_transaction(&self) -> Result<RuntimeStatementResult<P>>
pub fn rollback_transaction(&self) -> Result<RuntimeStatementResult<P>>
Rollback the current transaction, discarding all changes.
Sourcepub fn create_table_plan(
&self,
plan: CreateTablePlan,
) -> Result<RuntimeStatementResult<P>>
pub fn create_table_plan( &self, plan: CreateTablePlan, ) -> Result<RuntimeStatementResult<P>>
Create a table (outside or inside transaction).
Sourcepub fn insert(&self, plan: InsertPlan) -> Result<RuntimeStatementResult<P>>
pub fn insert(&self, plan: InsertPlan) -> Result<RuntimeStatementResult<P>>
Insert rows (outside or inside transaction).
Sourcepub fn select(&self, plan: SelectPlan) -> Result<RuntimeStatementResult<P>>
pub fn select(&self, plan: SelectPlan) -> Result<RuntimeStatementResult<P>>
Select rows (outside or inside transaction).
Sourcepub fn table_rows(&self, table: &str) -> Result<Vec<Vec<PlanValue>>>
pub fn table_rows(&self, table: &str) -> Result<Vec<Vec<PlanValue>>>
Convenience helper to fetch all rows from a table within this session.
Sourcepub fn update(&self, plan: UpdatePlan) -> Result<RuntimeStatementResult<P>>
pub fn update(&self, plan: UpdatePlan) -> Result<RuntimeStatementResult<P>>
Update rows (outside or inside transaction).
Sourcepub fn delete(&self, plan: DeletePlan) -> Result<RuntimeStatementResult<P>>
pub fn delete(&self, plan: DeletePlan) -> Result<RuntimeStatementResult<P>>
Delete rows (outside or inside transaction).
Auto Trait Implementations§
impl<P> Freeze for RuntimeSession<P>
impl<P> RefUnwindSafe for RuntimeSession<P>where
P: RefUnwindSafe,
impl<P> Send for RuntimeSession<P>
impl<P> Sync for RuntimeSession<P>
impl<P> Unpin for RuntimeSession<P>
impl<P> UnwindSafe for RuntimeSession<P>where
P: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more