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 methods
fn init(&mut self) -> BehaviorActed<Self>;
fn transition(&mut self, event: Self::Event) -> BehaviorActed<Self>;
// Provided methods
fn receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> BehaviorActed<Self>
where Self: Sized { ... }
fn on<Input>(&mut self, input: Input) -> BehaviorActed<Self>
where Self: Sized,
Self::Event: EventInput<Input> { ... }
}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 init(&mut self) -> BehaviorActed<Self>
fn init(&mut self) -> BehaviorActed<Self>
Produce initialization actions before the first event is accepted.
§Errors
Returns the behavior’s declared controlled initialization failure.
Sourcefn transition(&mut self, event: Self::Event) -> BehaviorActed<Self>
fn transition(&mut self, 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 receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> BehaviorActed<Self>where
Self: Sized,
fn receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> BehaviorActed<Self>where
Self: Sized,
Fold one user communication through the composed protocol.
§Errors
Returns the behavior’s declared controlled transition failure.
Sourcefn on<Input>(&mut self, input: Input) -> BehaviorActed<Self>
fn on<Input>(&mut self, input: Input) -> BehaviorActed<Self>
Inject one supported semantic input and fold it through this behavior.
This method exists only when the concrete composed protocol proves that
it contains Input; unsupported lanes therefore fail to compile.
§Errors
Returns the behavior’s declared controlled transition failure.