Module near_async::messaging
source · Structs§
- Sometimes we want to be able to pass in a sender that has not yet been fully constructed. LateBoundSender can act as a placeholder to pass CanSend and CanSendAsync capabilities through to the inner object. bind() should be called when the inner object is ready. All calls to send() and send_async() through this wrapper will block until bind() is called.
- Used to implement an async sender. An async sender is just a Sender whose message is
MessageWithCallback<M, R>
, which is a message plus a callback function (which resolves the future that send_async returns). - Wraps a CanSend. This should be used to pass around an Arc<dyn CanSend
>, instead of spelling out that type. Using a wrapper struct allows us to define more flexible APIs.
Enums§
- Generic failure for async send.
Traits§
- Trait for an actor. An actor is a struct that can handle messages and implementes the Handler or HandlerWithContext trait. We can optionally implement the start_actor trait which is executed in the beginning of the actor’s lifecycle. This corresponds to the actix::Actor trait
started
function. - Trait for sending a typed message. The sent message is then handled by the Handler trait. actix::Addr, which is derived from actix::Actor is an example of a struct that implements CanSend. See
Handler
trait for more details. - Trait for handling a message. This works in unison with the
CanSend
trait. An actor implements the Handler trait for all messages it would like to handle, while the CanSend trait implements the logic to send the message to the actor. Handle and CanSend are typically not both implemented by the same struct. Note that the actor is any struct that implements the Handler trait, not just actix actors. - Trait for handling a message with context. This is similar to the
Handler
trait, but it allows the handler to access the delayed action runner that is used to schedule actions to be run in the future. For actix::Actor, the context defined as actix::Contextimplements DelayedActionRunner . Note that the implementer for hander of a message only needs to implement either of Handler or HandlerWithContext, not both. - A trait for converting something that implements individual senders into a multi-sender.
- Extension functions to wrap a CanSend as a Sender.
- Extension trait (not for anyone to implement), that allows a Sender<MessageWithCallback<M, R>> to be used to send a message and then getting a future of the response.
Functions§
- Creates a no-op sender that does nothing with the message.