[−][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
[src]
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
[src]
The type of state maintained by the actor.
Example
#[derive(Clone, Debug, Eq, Hash, PartialEq)] struct MyActorState { sequencer: u64 }
Required methods
pub fn on_start(&self, id: Id, o: &mut Out<Self>)
[src]
Indicates the initial state and commands.
pub 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>
)
Indicates the next state and commands when a message is received. See Out::send
.
Provided methods
pub fn on_timeout(&self, _id: Id, _state: &Self::State, _o: &mut Out<Self>)
[src]
Indicates the next state and commands when a timeout is encountered. See Out::set_timer
.
pub fn on_start_out(&self, id: Id) -> Out<Self>
[src]
Returns the initial state and commands.
pub fn on_msg_out(
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg
) -> Out<Self>
[src]
&self,
id: Id,
state: &Self::State,
src: Id,
msg: Self::Msg
) -> Out<Self>
Returns the next state and commands when a message is received.
pub fn on_timeout_out(&self, id: Id, state: &Self::State) -> Out<Self>
[src]
Returns the next state and commands when a timeout is encountered.
Implementations on Foreign Types
impl Actor for ()
[src]
Implemented only for rustdoc. Do not take a dependency on this. It will likely be removed in a future version of this library.
type State = ()
type Msg = ()
pub fn on_start(&self, _: Id, o: &mut Out<Self>)
[src]
pub fn on_msg(
&self,
_: Id,
_: &Self::State,
_: Id,
_: Self::Msg,
_: &mut Out<Self>
)
[src]
&self,
_: Id,
_: &Self::State,
_: Id,
_: Self::Msg,
_: &mut Out<Self>
)
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>
pub fn on_start(&self, id: Id, o: &mut Out<Self>)
[src]
pub 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>
)
pub 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,