pub trait ReceivedCommand<C: Command>: Deref<Target = C> {
// Required methods
fn ack(&self) -> impl Future<Output = Result<(), Error>> + Send;
fn reply(
&self,
response: C::Reply,
) -> impl Future<Output = Result<(), Error>> + Send;
fn context(&self) -> &Context;
// Provided method
fn command(&self) -> &C { ... }
}Expand description
A received command that must be acknowledged with a typed reply.
Required Methods§
Sourcefn ack(&self) -> impl Future<Output = Result<(), Error>> + Send
fn ack(&self) -> impl Future<Output = Result<(), Error>> + Send
Take responsibility for the command without answering it yet.
A handler that acknowledges up front trades the certainty of
eventually receiving an answer for the certainty that nothing can hand
the command out a second time: a crash or a stall past this point costs
the reply rather than repeating whatever the handler had already done.
This is what a Delivery::AtMostOnce command asks for:
ⓘ
received.ack().await?;
let reply = claim_keys(received.command()).await;
received.reply(reply).await?;reply acknowledges as well, so a handler that is happy
to be run again should never call this.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".