pub trait Actor:
Sized
+ Send
+ Sync
+ 'static {
type Message: ActorMessage<Self>;
type Spec: Send;
type Channel: ActorChannel<Message = Self::Message>;
type Cancel: Clone + Debug + Default + Send + Sync + 'static;
type State: Send + Sync + 'static;
// Required methods
fn state(spec: &Self::Spec) -> Self::State;
fn init(ctx: Init<'_, Self>) -> impl InitFuture<Self>;
// Provided methods
fn span(_spec: &Self::Spec) -> Span { ... }
fn termination_strategy(&mut self) -> Terminate { ... }
fn terminate(
self,
_ctx: ActorContext<Self>,
_reason: CancelReason<Self::Cancel>,
) -> impl Future<Output = ()> + Send { ... }
fn tick(&mut self) -> impl Future<Output = ControlFlow<Self::Cancel>> + Send { ... }
fn cycle(
&mut self,
ctx: &mut ActorContext<Self>,
) -> impl Future<Output = ControlFlow<CancelReason<Self::Cancel>, ()>> + Send { ... }
fn crash(err: JoinError) -> impl Future<Output = ()> + Send { ... }
fn handle<'a>(
&'a mut self,
_ctx: Exec<'a, Self>,
msg: Self::Message,
) -> impl Future<Output = ()> + Send + 'a { ... }
fn spawn(spec: Self::Spec) -> Link<Self> { ... }
}Required Associated Types§
type Message: ActorMessage<Self>
type Spec: Send
type Channel: ActorChannel<Message = Self::Message>
type Cancel: Clone + Debug + Default + Send + Sync + 'static
type State: Send + Sync + 'static
Required Methods§
fn state(spec: &Self::Spec) -> Self::State
fn init(ctx: Init<'_, Self>) -> impl InitFuture<Self>
Provided Methods§
fn span(_spec: &Self::Spec) -> Span
fn termination_strategy(&mut self) -> Terminate
fn terminate( self, _ctx: ActorContext<Self>, _reason: CancelReason<Self::Cancel>, ) -> impl Future<Output = ()> + Send
fn tick(&mut self) -> impl Future<Output = ControlFlow<Self::Cancel>> + Send
fn cycle( &mut self, ctx: &mut ActorContext<Self>, ) -> impl Future<Output = ControlFlow<CancelReason<Self::Cancel>, ()>> + Send
fn crash(err: JoinError) -> impl Future<Output = ()> + Send
fn handle<'a>( &'a mut self, _ctx: Exec<'a, Self>, msg: Self::Message, ) -> impl Future<Output = ()> + Send + 'a
fn spawn(spec: Self::Spec) -> Link<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.