pub struct HookOperation<'c> { /* private fields */ }Expand description
Wrapper around a database connection passed to CommitHook::pre_commit().
Implements AtomicOperation to allow executing database queries within the
transaction. Whether it also supports registering further commit hooks depends
on how it was constructed — see the staged field below and “Re-entrant
Registration” in the module docs.
Trait Implementations§
Source§impl<'c> AtomicOperation for HookOperation<'c>
impl<'c> AtomicOperation for HookOperation<'c>
Source§fn savepoint_parts(&mut self) -> (&mut Connection, HookSlot<'_>)
fn savepoint_parts(&mut self) -> (&mut Connection, HookSlot<'_>)
Lets a hook’s own pre_commit isolate its multi-statement work in a
SAVEPOINT — see SavepointOperation.
Hooks registered inside stage normally and, on
release, fold into this
HookOperation’s own buffer exactly like a top-level savepoint folds
into a DbOp — if this HookOperation is on a real commit pass
(supports_hooks is true). On the
force_execute_pre_commit path
staged is None, so registering a hook inside the savepoint fails the
same way it would have on this HookOperation directly — the
SAVEPOINT/RELEASE/ROLLBACK machinery itself still works, since it
needs only the connection.
Source§fn maybe_now(&self) -> Option<DateTime<Utc>>
fn maybe_now(&self) -> Option<DateTime<Utc>>
Source§fn connection(&mut self) -> &mut Connection
fn connection(&mut self) -> &mut Connection
Source§fn add_commit_hook<H: CommitHook>(&mut self, hook: H) -> Result<(), H>
fn add_commit_hook<H: CommitHook>(&mut self, hook: H) -> Result<(), H>
Source§fn commit_hook<H: CommitHook>(&self) -> Option<&H>
fn commit_hook<H: CommitHook>(&self) -> Option<&H>
H,
if this operation supports commit hooks and one is registered.
Returns the hook a subsequent add_commit_hook::<H> call would merge into.Source§fn supports_hooks(&self) -> bool
fn supports_hooks(&self) -> bool
Source§fn clock(&self) -> &ClockHandle
fn clock(&self) -> &ClockHandle
Source§fn as_executor(&mut self) -> OneTimeExecutor<'_, &mut Connection>
fn as_executor(&mut self) -> OneTimeExecutor<'_, &mut Connection>
sqlx::Executor implementation that statements should be
executed through. Read moreAuto Trait Implementations§
impl<'c> !RefUnwindSafe for HookOperation<'c>
impl<'c> !Sync for HookOperation<'c>
impl<'c> !UnwindSafe for HookOperation<'c>
impl<'c> Freeze for HookOperation<'c>
impl<'c> Send for HookOperation<'c>
impl<'c> Unpin for HookOperation<'c>
impl<'c> UnsafeUnpin for HookOperation<'c>
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 moreSource§impl<T> SavepointOperation for Twhere
T: AtomicOperation + ?Sized,
impl<T> SavepointOperation for Twhere
T: AtomicOperation + ?Sized,
Source§fn with_savepoint<T, E, F>(
&mut self,
f: F,
) -> impl Future<Output = Result<Result<T, E>, Error>>
fn with_savepoint<T, E, F>( &mut self, f: F, ) -> impl Future<Output = Result<Result<T, E>, Error>>
f inside a SAVEPOINT, keeping its work on Ok and undoing it on
Err — see DbOp::with_savepoint for the
full contract, including the two layers of Result. Read moreSource§fn begin_savepoint(
&mut self,
) -> impl Future<Output = Result<SavepointOp<'_>, Error>> + Send
fn begin_savepoint( &mut self, ) -> impl Future<Output = Result<SavepointOp<'_>, Error>> + Send
SAVEPOINT scope explicitly — see
DbOp::begin_savepoint. Must be finished
with release or
rollback; dropping it rolls back. Read more