pub struct SessionGuard { /* private fields */ }Expand description
RAII guard for session-scoped transactions.
Created via SessionGuard::begin(), which calls control.begin().
On drop, automatically calls control.rollback() unless commit()
was called first.
Implementations§
Source§impl SessionGuard
impl SessionGuard
Sourcepub async fn begin(control: Arc<dyn SessionControl>) -> Result<Self, IndexError>
pub async fn begin(control: Arc<dyn SessionControl>) -> Result<Self, IndexError>
Begin a new session, returning an RAII guard.
Calls control.begin() and returns a guard that will automatically
roll back on drop unless commit() is called.
Sourcepub async fn commit(self) -> Result<(), IndexError>
pub async fn commit(self) -> Result<(), IndexError>
Commit the session-scoped transaction.
Marks the guard as committed so that Drop will not roll back.
The committed flag is set only after a successful commit — if
control.commit() fails, Drop will still trigger rollback.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionGuard
impl !RefUnwindSafe for SessionGuard
impl Send for SessionGuard
impl Sync for SessionGuard
impl Unpin for SessionGuard
impl UnsafeUnpin for SessionGuard
impl !UnwindSafe for SessionGuard
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
Mutably borrows from an owned value. Read more