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

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?;
}

Consume the Cancel wrapper to take the underlying message

After calling this function it is no longer possible to re-queue the message into the worker mailbox.

Trait Implementations

Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more