Actor

Trait Actor 

Source
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§

Source

type Message: ActorMessage<Self>

Source

type Spec: Send

Source

type Channel: ActorChannel<Message = Self::Message>

Source

type Cancel: Clone + Debug + Default + Send + Sync + 'static

Source

type State: Send + Sync + 'static

Required Methods§

Source

fn state(spec: &Self::Spec) -> Self::State

Source

fn init(ctx: Init<'_, Self>) -> impl InitFuture<Self>

Provided Methods§

Source

fn span(_spec: &Self::Spec) -> Span

Source

fn termination_strategy(&mut self) -> Terminate

Source

fn terminate( self, _ctx: ActorContext<Self>, _reason: CancelReason<Self::Cancel>, ) -> impl Future<Output = ()> + Send

Source

fn tick(&mut self) -> impl Future<Output = ControlFlow<Self::Cancel>> + Send

Source

fn cycle( &mut self, ctx: &mut ActorContext<Self>, ) -> impl Future<Output = ControlFlow<CancelReason<Self::Cancel>, ()>> + Send

Source

fn crash(err: JoinError) -> impl Future<Output = ()> + Send

Source

fn handle<'a>( &'a mut self, _ctx: Exec<'a, Self>, msg: Self::Message, ) -> impl Future<Output = ()> + Send + 'a

Source

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.

Implementors§