pub struct TransactionRunner<'a, H = (), P = NativeRetryPolicy> { /* private fields */ }Expand description
Builder for a transactional run, returned by
Database::runner.
It assembles the RunnerHooks and the RetryPolicy of a single call to
run: no hooks and NativeRetryPolicy by default. Both are
borrowed, so the same hooks and policy can be reused across runs (mind
MetricsHooks, which times the run from its own construction).
db.runner()
.run(|trx, _| async move {
trx.set(b"key", b"value");
Ok::<_, FdbBindingError>(())
})
.awaitImplementations§
Source§impl<'a, H, P> TransactionRunner<'a, H, P>
impl<'a, H, P> TransactionRunner<'a, H, P>
Sourcepub fn hooks<H2>(self, hooks: &'a H2) -> TransactionRunner<'a, H2, P>
pub fn hooks<H2>(self, hooks: &'a H2) -> TransactionRunner<'a, H2, P>
Observes the run with hooks, replacing any hooks set before.
Stack several of them with a tuple: .hooks(&(first, second)).
Sourcepub fn retry_policy<P2>(self, policy: &'a P2) -> TransactionRunner<'a, H, P2>
pub fn retry_policy<P2>(self, policy: &'a P2) -> TransactionRunner<'a, H, P2>
Decides the retries with policy instead of NativeRetryPolicy.
Sourcepub async fn run<F, Fut, T, E>(self, closure: F) -> Result<T, E>where
F: Fn(RetryableTransaction, MaybeCommitted) -> Fut,
Fut: Future<Output = Result<T, E>>,
E: RetryableError,
H: RunnerHooks,
P: RetryPolicy<E>,
pub async fn run<F, Fut, T, E>(self, closure: F) -> Result<T, E>where
F: Fn(RetryableTransaction, MaybeCommitted) -> Fut,
Fut: Future<Output = Result<T, E>>,
E: RetryableError,
H: RunnerHooks,
P: RetryPolicy<E>,
Runs closure in a transaction, retrying it until it commits or the
error is fatal.
See Database::run for the semantics of the
closure, its error type and the retries.
Auto Trait Implementations§
impl<'a, H, P> Freeze for TransactionRunner<'a, H, P>
impl<'a, H, P> RefUnwindSafe for TransactionRunner<'a, H, P>where
H: RefUnwindSafe,
P: RefUnwindSafe,
impl<'a, H, P> Send for TransactionRunner<'a, H, P>
impl<'a, H, P> Sync for TransactionRunner<'a, H, P>
impl<'a, H, P> Unpin for TransactionRunner<'a, H, P>
impl<'a, H, P> UnwindSafe for TransactionRunner<'a, H, P>where
H: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more