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,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>;
fn transition(
&mut self,
event: Self::Event,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>;
// Provided methods
fn receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
where Self: Sized { ... }
fn on<Input>(
&mut self,
input: Input,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
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§
Provided Methods§
Sourcefn receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>where
Self: Sized,
fn receive(
&mut self,
from: Self::Addr,
message: Self::Msg,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>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,
) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
fn on<Input>( &mut self, input: Input, ) -> Result<Actions<Self::Addr, Self::Ph, Self::Sends, Self::Birth>, Self::Error>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".