[−][src]Trait stateright::actor::Actor
An actor initializes internal state optionally emitting outputs; then it waits for incoming events, responding by updating its internal state and optionally emitting outputs.
Associated Types
type Msg: Clone + Debug + Eq + Hash
The type of messages sent and received by the actor.
Example
use serde_derive::{Deserialize, Serialize}; #[derive(Clone, Debug, Eq, Hash, PartialEq)] #[derive(Serialize, Deserialize)] enum MyActorMsg { Msg1(u64), Msg2(char) }
type State: Clone + Debug + PartialEq + Hash
The type of state maintained by the actor.
Example
#[derive(Clone, Debug, Eq, Hash, PartialEq)] struct MyActorState { sequencer: u64 }
Required methods
fn on_start(&self, id: Id, o: &mut Out<Self>)
Indicates the initial state and commands.
fn on_msg(
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg,
o: &mut Out<Self>
)
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg,
o: &mut Out<Self>
)
Indicates the next state and commands when a message is received. See Out::send
.
Provided methods
fn on_timeout(&self, _id: Id, _state: &Self::State, _o: &mut Out<Self>)
Indicates the next state and commands when a timeout is encountered. See Out::set_timer
.
fn on_start_out(&self, id: Id) -> Out<Self>
Returns the initial state and commands.
fn on_msg_out(
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg
) -> Out<Self>
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg
) -> Out<Self>
Returns the next state and commands when a message is received.
fn on_timeout_out(&self, id: Id, state: &Self::State) -> Out<Self>
Returns the next state and commands when a timeout is encountered.
Implementors
impl<A: Actor> Actor for ActorWrapper<A> where
A::Msg: Hash,
[src]
A::Msg: Hash,
type Msg = MsgWrapper<A::Msg>
type State = StateWrapper<A::Msg, A::State>
fn on_start(&self, id: Id, o: &mut Out<Self>)
[src]
fn on_msg(
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg,
o: &mut Out<Self>
)
[src]
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg,
o: &mut Out<Self>
)
fn on_timeout(&self, _id: Id, state: &Self::State, o: &mut Out<Self>)
[src]
impl<ServerActor, InternalMsg> Actor for RegisterActor<ServerActor> where
ServerActor: Actor<Msg = RegisterMsg<TestRequestId, TestValue, InternalMsg>>,
InternalMsg: Clone + Debug + Eq + Hash,
[src]
ServerActor: Actor<Msg = RegisterMsg<TestRequestId, TestValue, InternalMsg>>,
InternalMsg: Clone + Debug + Eq + Hash,