Crate xtra

Source
Expand description

xtra is a tiny, fast, and safe actor system.

Re-exports§

pub use self::address::Address;
pub use self::address::WeakAddress;
pub use self::scoped_task::scoped;

Modules§

address
An address to an actor is a way to send it a message. An address allows an actor to be sent any kind of message that it can receive.
message_channel
A message channel is a channel through which you can send only one kind of message, but to any actor that can handle it. It is like Address, but associated with the message type rather than the actor type.
prelude
Commonly used types from xtra
refcount
This module contains types representing the strength of an address’s reference counting, which influences whether the address will keep the actor alive for as long as it lives.
scoped_task
This module contains a way to scope a future to the lifetime of an actor, stopping it before it completes if the actor it is associated with stops too.

Structs§

ActorErasedSending
“Sending” state of SendFuture for cases where the actor type is erased.
ActorNamedSending
“Sending” state of SendFuture for cases where the actor type is named and we sent a single message.
Context
Context is used to control how the actor is managed and to get the actor’s address from inside of a message handler.
Mailbox
A Mailbox is the counter-part to an Address.
Receiver
A Future that resolves to the Return value of a Handler.
SendFuture
A Future that represents the state of sending a message to an actor.

Enums§

Error
An error related to the actor system

Traits§

Actor
An actor which can handle message one at a time. Actors can only be communicated with by sending messages through their Addresses. They can modify their private state, respond to messages, and spawn other actors. They can also stop themselves through their Context by calling Context::stop_self. This will result in any attempt to send messages to the actor in future failing.
Handler
Defines that an Actor can handle a given message M.

Functions§

join
Joins on a future by handling all incoming messages whilst polling it. The future will always be polled to completion, even if the actor is stopped. If the actor is stopped, handling of messages will cease, and only the future will be polled. It is somewhat analagous to futures::join, but it will not wait for the incoming stream of messages from addresses to end before returning - it will return as soon as the provided future does.
run
Run the provided actor.
select
Handle any incoming messages for the actor while running a given future. This is similar to join, but will exit if the actor is stopped, returning the future. Returns Ok with the result of the future if it was successfully completed, or Err with the future if the actor was stopped before it could complete. It is analagous to futures::select.
spawn_async_stdasync_std
Spawns the given actor into the async_std runtime, returning an Address to it.
spawn_smolsmol
Spawns the given actor into the smol runtime, returning an Address to it.
spawn_tokiotokio
Spawns the given actor into the tokio runtime, returning an Address to it.
spawn_wasm_bindgenwasm_bindgen
Spawns the given actor onto the thread-local runtime via wasm_bindgen_futures, returning an Address to it.
yield_once
Yields to the manager to handle one message, returning the actor should be shut down or not.