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§
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 Methods§
Sourcefn transition(
&mut self,
_turn: ActiveTurn,
event: Self::Event,
) -> BehaviorActed<Self>
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§
Sourcefn init(&mut self, _turn: InitializationTurn) -> BehaviorActed<Self>where
Self: Sized,
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".