- Sealed
RefCounter
,MessageChannel
, andMessageSink
traits
- The
SyncHandler
trait has been removed. This simplifies the API and should not change the performance on stable.- How to upgrade: change all implementations of the
SyncHandler
trait to the normalHandler
trait.
- How to upgrade: change all implementations of the
- All
Actor
lifecycle messages are now async. This allows to do more kinds of things in lifecycle methods, while adding no restrictions.- How to upgrade: add
async
to the function definition of all actor lifecycle methods, add#[async_trait::async_trait]
to theimpl Actor
block.
- How to upgrade: add
Actor
now requiresSend
to implement. Previously, the trait itself did not, but using it did requireSend
.- How to upgrade: you probably never had a non-
Send
actor in the first place.
- How to upgrade: you probably never had a non-
- The
{Weak}{Address|MessageChannel}::attach_stream
methods now require that the actor implementsHandler<M>
whereM: Into<KeepRunning> + Send
. This is automatically implemented for()
, returningKeepRunning::Yes
. This allows the user more control over the future spawned byattach_stream
, but is breaking if the message returned did not implementInto<KeepRunning>
.- How to upgrade: implement
Into<KeepRunning>
for all message types used inattach_stream
. To mimic previous behaviour, returnKeepRunning::Yes
in the implementation.
- How to upgrade: implement
Address
andWeakAddress
lost theirSink
implementations. They can now be turned intoSink
s by calling.into_sink()
.- How to upgrade: convert any addresses to be used as sinks into sinks with
.into_sink()
, cloning where necessary.
- How to upgrade: convert any addresses to be used as sinks into sinks with
{Address|MessageChannel}Ext
were removed in favour of inherent implementations,- How to upgrade: in most cases, this will not have broken anything. If it is directly imported, remove the import.
If you need to be generic over weak and strong addresses, be generic over
Address<A, Rc>
whereRc: RefCounter
for addresses and useMessageChannel<M>
trait objects.
- How to upgrade: in most cases, this will not have broken anything. If it is directly imported, remove the import.
If you need to be generic over weak and strong addresses, be generic over
{Weak}MessageChannel
became traits rather than concrete types. In order to use them, simply cast an address to the correct trait object (e.g&addr as &dyn MessageChannel<M>
orBox::new(addr)
). Theinto_channel
andchannel
methods were also removed.- How to upgrade: replace
{into_}channel
calls with casts to trait objects, and replace references to the old types with trait objects, boxed if necessary. If you were using theSink
implementations of these types, first create anAddressSink
through.into_sink()
, and then cast it to aMessageSink
trait object.
- How to upgrade: replace
Address::into_downgraded
was removed. This did nothing different todowngrade
, except dropping the address after the call.- How to upgrade: Simply call
Address::downgrade
, dropping the strong address afterwards if needed.
- How to upgrade: Simply call
- Some types were moved out of the root crate and into modules.
- How to upgrade: search for the type's name in the documentation and refer to it by its new path.
Actor::spawn
andActor::create
now take anOption<usize>
for the mailbox size.- How to upgrade: choose a suitable size of mailbox for each spawn call, or pass
None
to give them unbounded mailboxes.
- How to upgrade: choose a suitable size of mailbox for each spawn call, or pass
- Many context methods now return
Result<..., ActorShutdown>
to represent failures due to the actor having been shut down.
- The
stable
feature was removed.In order to enable the nightly API, enable the newEdit: as of 0.5.0, the nightly API has been removed.nightly
feature.
- The default API of the
Handler
trait has now changed to anasync_trait
so that xtra can compile on stable.- How to upgrade, alternative 1: change the implementations by annotating the implementation with
#[async_trait]
, removingResponder
and makinghandle
anasync fn
which directly returns the message's result. - How to upgrade, alternative 2: if you want to avoid the extra box, you can disable the default
stable
feature in yourCargo.toml
to keep the old API.
- How to upgrade, alternative 1: change the implementations by annotating the implementation with
- Removal of the
with-runtime
feature- How to upgrade: you probably weren't using this anyway, but rather use
with-tokio-*
orwith-async_std-*
instead.
- How to upgrade: you probably weren't using this anyway, but rather use
Address
methods were moved toAddressExt
to accommodate newAddress
types- How to upgrade: add
use xtra::AddressExt
to wherever address methods are used (or, better yet,use xtra::prelude::*
)
- How to upgrade: add
- All
*_async
methods were removed. Asynchronous and synchronous messages now use the same method for everything.- How to upgrade: simply switch from the
[x]_async
method to the[x]
method.
- How to upgrade: simply switch from the
AsyncHandler
was renamed toHandler
, and the oldHandler
toSyncHandler
. Also, aHandler
andSyncHandler
implementation can no longer coexist.- How to upgrade: rename all
Handler
implementations toSyncHandler
, and allAsyncHandler
implementations toHandler
.
- How to upgrade: rename all