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§
- 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.
- 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. - Commonly used types from xtra
- 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.
- 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§
- “Sending” state of
SendFuture
for cases where the actor type is erased. - “Sending” state of
SendFuture
for cases where the actor type is named and we sent a single message. Context
is used to control how the actor is managed and to get the actor’s address from inside of a message handler.- A
Future
that represents the state of sending a message to an actor.
Enums§
- An error related to the actor system
Traits§
- An actor which can handle message one at a time. Actors can only be communicated with by sending messages through their
Address
es. They can modify their private state, respond to messages, and spawn other actors. They can also stop themselves through theirContext
by callingContext::stop_self
. This will result in any attempt to send messages to the actor in future failing. - Defines that an
Actor
can handle a given messageM
.
Functions§
- 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 the provided actor.
- 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. ReturnsOk
with the result of the future if it was successfully completed, orErr
with the future if the actor was stopped before it could complete. It is analagous tofutures::select
. - spawn_async_std
async_std
Spawns the given actor into the async_std runtime, returning anAddress
to it. - spawn_smol
smol
Spawns the given actor into the smol runtime, returning anAddress
to it. - spawn_tokio
tokio
Spawns the given actor into the tokio runtime, returning anAddress
to it. - spawn_wasm_bindgen
wasm_bindgen
Spawns the given actor onto the thread-local runtime viawasm_bindgen_futures
, returning anAddress
to it. - Yields to the manager to handle one message, returning the actor should be shut down or not.