Crate xtra

source ·
Expand description

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

Re-exports§

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§

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 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.
  • Defines that an Actor can handle a given message M.

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. 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.
  • Spawns the given actor into the async_std runtime, returning an Address to it.
  • Spawns the given actor into the smol runtime, returning an Address to it.
  • 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.
  • Yields to the manager to handle one message, returning the actor should be shut down or not.