Skip to main content

Behavior

Trait Behavior 

Source
pub trait Behavior {
    type Addr: Address;
    type Msg;
    type Event: UserEvent<Addr = Self::Addr, Message = Self::Msg>;
    type Sends: SendAlgebra;
    type Ph;
    type Error;
    type Birth: BirthMode;

    // Required method
    fn transition(
        &mut self,
        _turn: ActiveTurn,
        event: Self::Event,
    ) -> BehaviorActed<Self>;

    // Provided method
    fn init(&mut self, _turn: InitializationTurn) -> BehaviorActed<Self>
       where Self: Sized { ... }
}
Expand description

A composed pure behavior. Event is the complete accepted protocol; every successful transition returns the declared Actions value.

Required Associated Types§

Source

type Addr: Address

Source

type Msg

Source

type Event: UserEvent<Addr = Self::Addr, Message = Self::Msg>

Source

type Sends: SendAlgebra

Source

type Ph

Source

type Error

Source

type Birth: BirthMode

Required Methods§

Source

fn transition( &mut self, _turn: ActiveTurn, event: Self::Event, ) -> BehaviorActed<Self>

Fold exactly one event into explicit actions and the next behavior.

§Errors

Returns the behavior’s declared controlled transition failure.

Provided Methods§

Source

fn init(&mut self, _turn: InitializationTurn) -> BehaviorActed<Self>
where Self: Sized,

Produce initialization actions before the first event is accepted.

§Errors

Returns the behavior’s declared controlled initialization failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§