[][src]Crate xtra

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

Modules

prelude

Commonly used types from xtra

Structs

ActorManager

A manager for the actor which handles incoming messages and stores the context. Its managing loop can be started with ActorManager::manage.

Address

An Address is a reference to an actor through which Messages can be sent. It can be cloned, and when all Addresses are dropped, the actor will be stopped. Therefore, any existing Addresses will inhibit the dropping of an actor. If this is undesirable, then the WeakAddress struct should be used instead. This struct is created by calling the Actor::create or Actor::spawn methods.

Context

Context is used to control how the actor is managed and to get the actor's address from inside of a message handler.

Disconnected

The actor is no longer running and disconnected from the sending address. For why this could occur, see the Actor::stopping and Actor::stopped methods.

MessageChannel

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. Any existing MessageChannels will prevent the dropping of the actor. If this is undesirable, then the WeakMessageChannel struct should be used instead. This struct is created by calling Address::channel, Address::into_channel, or the similar methods on WeakAddress.

MessageResponseFuture

The future returned by a method such as AddressExt::send. It resolves to Result<M::Result, Disconnected>.

WeakAddress

A WeakAddress is a reference to an actor through which Messages can be sent. It can be cloned. Unlike Address, a WeakAddress will not inhibit the dropping of an actor. It is created by the Address::downgrade or Address::into_downgraded methods.

WeakMessageChannel

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. Any existing WeakMessageChannels will not prevent the dropping of the actor. If this is undesirable, then the MessageChannel struct should be used instead. This struct is created by calling MessageChannel::downgrade MessageChannel::into_downgraded, WeakAddress::channel, or WeakAddress::into_channel.

Enums

KeepRunning

Whether to keep the actor running after it has been put into a stopping state.

Traits

Actor

An actor which can handle Messages 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. This will result in any attempt to send messages to the actor in future failing.

AddressExt

General trait for any kind of address to an actor, be it strong or weak. This trait contains all functions of the address.

Handler

A trait indicating that an Actor can handle a given Message asynchronously, and the logic to handle the message. If the message should be handled synchronously, then the SyncHandler trait should rather be implemented.

Message

A message that can be sent to an Actor for processing. They are processed one at a time. Only actors implementing the corresponding Handler<M> trait can be sent a given message.

MessageChannelExt

General trait for any kind of channel of messages, be it strong or weak. This trait contains all functions of the channel.

SyncHandler

A trait indicating that an Actor can handle a given Message synchronously, and the logic to handle the message. A SyncHandler implementation automatically creates a corresponding Handler impl. This, however, is not just sugar over the asynchronous Handler trait -- it is also slightly faster than it for handling due to how they get specialized under the hood.