pub enum ActoInput<M, S> {
NoMoreSenders,
Supervision {
id: ActoId,
name: String,
result: Result<S, PanicOrAbort>,
},
Message(M),
}Expand description
Actor input as received with [ActoCell::recv].
Variants§
NoMoreSenders
All previously generated [ActoRef] handles were dropped, leaving only
the one within [ActoCell]; the actor may wish to terminate unless it has
other sources of input.
Obtaining a new handle with [ActoCell::me] and dropping it will again
generate this input.
Supervision
A supervised actor with the given ActoId has terminated.
The result contains either the value returned by the actor or the value with which the actor’s task panicked (if the underlying runtime handles this).
§Important notice
Supervision notifications are delivered as soon as possible after the supervised actor’s task has finished. Messages sent by that actor — possibly to the supervisor — may still be in flight at this point.
Message(M)
A message has been received via our [ActoRef] handle.
Implementations§
Source§impl<M, S> ActoInput<M, S>
impl<M, S> ActoInput<M, S>
pub fn is_sender_gone(&self) -> bool
pub fn is_supervision(&self) -> bool
pub fn is_message(&self) -> bool
Sourcepub fn has_senders(self) -> Option<ActoMsgSuper<M, S>>
pub fn has_senders(self) -> Option<ActoMsgSuper<M, S>>
Obtain input message or supervision unless this is ActoInput::NoMoreSenders.
use acto::{ActoCell, ActoRuntime};
async fn actor(mut cell: ActoCell<String, impl ActoRuntime>) {
while let Some(input) = cell.recv().await.has_senders() {
// do something with it
}
// actor automatically stops when all senders are gone
}