Struct ockam_node::Cancel
source · [−]pub struct Cancel<'ctx, M: Message> { /* private fields */ }
Expand description
A message wrapper type that allows users to cancel message receival
A worker can block in place to wait for a message. If the next message is not the desired type, it can be cancelled which re-queues it into the mailbox.
Implementations
sourceimpl<'ctx, M: Message> Cancel<'ctx, M>
impl<'ctx, M: Message> Cancel<'ctx, M>
sourcepub async fn cancel(self) -> Result<()>
pub async fn cancel(self) -> Result<()>
Cancel this message
This results in the message being re-queued at the back of the worker’s mailbox so that it can be handled by a future handle_message call
use ockam_node::Context;
use ockam_core::Result;
let msg = ctx.receive::<String>().await?;
if &*msg != "hello ockam" {
msg.cancel().await?;
}
Trait Implementations
Auto Trait Implementations
impl<'ctx, M> !RefUnwindSafe for Cancel<'ctx, M>
impl<'ctx, M> Send for Cancel<'ctx, M>
impl<'ctx, M> Sync for Cancel<'ctx, M>where
M: Sync,
impl<'ctx, M> Unpin for Cancel<'ctx, M>where
M: Unpin,
impl<'ctx, M> !UnwindSafe for Cancel<'ctx, M>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more