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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more