Struct stateright::actor::ActorModel
source · pub struct ActorModel<A, C = (), H = ()>where
A: Actor,
H: Clone + Debug + Hash,{
pub actors: Vec<A>,
pub cfg: C,
pub init_history: H,
pub init_network: Network<A::Msg>,
pub lossy_network: LossyNetwork,
pub max_crashes: usize,
pub properties: Vec<Property<ActorModel<A, C, H>>>,
pub record_msg_in: fn(cfg: &C, history: &H, envelope: Envelope<&A::Msg>) -> Option<H>,
pub record_msg_out: fn(cfg: &C, history: &H, envelope: Envelope<&A::Msg>) -> Option<H>,
pub within_boundary: fn(cfg: &C, state: &ActorModelState<A, H>) -> bool,
}
Expand description
Represents a system of Actor
s that communicate over a network. H
indicates the type of
history to maintain as auxiliary state, if any. See Auxiliary Variables in
TLA for a thorough
introduction to that concept. Use ()
if history is not needed to define the relevant
properties of this system.
Fields§
§actors: Vec<A>
§cfg: C
§init_history: H
§init_network: Network<A::Msg>
§lossy_network: LossyNetwork
§max_crashes: usize
Maximum number of actors that can be contemporarily crashed
properties: Vec<Property<ActorModel<A, C, H>>>
§record_msg_in: fn(cfg: &C, history: &H, envelope: Envelope<&A::Msg>) -> Option<H>
§record_msg_out: fn(cfg: &C, history: &H, envelope: Envelope<&A::Msg>) -> Option<H>
§within_boundary: fn(cfg: &C, state: &ActorModelState<A, H>) -> bool
Implementations§
source§impl<A, C, H> ActorModel<A, C, H>where
A: Actor,
H: Clone + Debug + Hash,
impl<A, C, H> ActorModel<A, C, H>where A: Actor, H: Clone + Debug + Hash,
sourcepub fn new(cfg: C, init_history: H) -> ActorModel<A, C, H>
pub fn new(cfg: C, init_history: H) -> ActorModel<A, C, H>
Initializes an ActorModel
with a specified configuration and history.
sourcepub fn actors(self, actors: impl IntoIterator<Item = A>) -> Self
pub fn actors(self, actors: impl IntoIterator<Item = A>) -> Self
Adds multiple Actor
s to this model.
sourcepub fn init_network(self, init_network: Network<A::Msg>) -> Self
pub fn init_network(self, init_network: Network<A::Msg>) -> Self
Defines the initial network.
sourcepub fn lossy_network(self, lossy_network: LossyNetwork) -> Self
pub fn lossy_network(self, lossy_network: LossyNetwork) -> Self
Defines whether the network loses messages or not.
sourcepub fn max_crashes(self, max_crashes: usize) -> Self
pub fn max_crashes(self, max_crashes: usize) -> Self
Specifies the maximum number of actors that can be contemporarily crashed
sourcepub fn property(
self,
expectation: Expectation,
name: &'static str,
condition: fn(_: &ActorModel<A, C, H>, _: &ActorModelState<A, H>) -> bool
) -> Self
pub fn property( self, expectation: Expectation, name: &'static str, condition: fn(_: &ActorModel<A, C, H>, _: &ActorModelState<A, H>) -> bool ) -> Self
Adds a Property
to this model.
sourcepub fn record_msg_in(
self,
record_msg_in: fn(cfg: &C, history: &H, _: Envelope<&A::Msg>) -> Option<H>
) -> Self
pub fn record_msg_in( self, record_msg_in: fn(cfg: &C, history: &H, _: Envelope<&A::Msg>) -> Option<H> ) -> Self
Defines whether/how an incoming message contributes to relevant history. Returning
Some(new_history)
updates the relevant history, while None
does not.
sourcepub fn record_msg_out(
self,
record_msg_out: fn(cfg: &C, history: &H, _: Envelope<&A::Msg>) -> Option<H>
) -> Self
pub fn record_msg_out( self, record_msg_out: fn(cfg: &C, history: &H, _: Envelope<&A::Msg>) -> Option<H> ) -> Self
Defines whether/how an outgoing message contributes to relevant history. Returning
Some(new_history)
updates the relevant history, while None
does not.
sourcepub fn within_boundary(
self,
within_boundary: fn(cfg: &C, state: &ActorModelState<A, H>) -> bool
) -> Self
pub fn within_boundary( self, within_boundary: fn(cfg: &C, state: &ActorModelState<A, H>) -> bool ) -> Self
Indicates whether a state is within the state space that should be model checked.
Trait Implementations§
source§impl<A, C: Clone, H> Clone for ActorModel<A, C, H>where
A: Actor + Clone,
H: Clone + Debug + Hash + Clone,
A::Msg: Clone,
impl<A, C: Clone, H> Clone for ActorModel<A, C, H>where A: Actor + Clone, H: Clone + Debug + Hash + Clone, A::Msg: Clone,
source§fn clone(&self) -> ActorModel<A, C, H>
fn clone(&self) -> ActorModel<A, C, H>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<A, C, H> Model for ActorModel<A, C, H>where
A: Actor,
H: Clone + Debug + Hash,
impl<A, C, H> Model for ActorModel<A, C, H>where A: Actor, H: Clone + Debug + Hash,
source§fn as_svg(&self, path: Path<Self::State, Self::Action>) -> Option<String>
fn as_svg(&self, path: Path<Self::State, Self::Action>) -> Option<String>
Draws a sequence diagram for the actor system.
§type State = ActorModelState<A, H>
type State = ActorModelState<A, H>
§type Action = ActorModelAction<<A as Actor>::Msg, <A as Actor>::Timer>
type Action = ActorModelAction<<A as Actor>::Msg, <A as Actor>::Timer>
source§fn init_states(&self) -> Vec<Self::State>
fn init_states(&self) -> Vec<Self::State>
source§fn actions(&self, state: &Self::State, actions: &mut Vec<Self::Action>)
fn actions(&self, state: &Self::State, actions: &mut Vec<Self::Action>)
source§fn next_state(
&self,
last_sys_state: &Self::State,
action: Self::Action
) -> Option<Self::State>
fn next_state( &self, last_sys_state: &Self::State, action: Self::Action ) -> Option<Self::State>
None
indicates that the action
does not change the state.source§fn format_action(&self, action: &Self::Action) -> String
fn format_action(&self, action: &Self::Action) -> String
source§fn format_step(
&self,
last_state: &Self::State,
action: Self::Action
) -> Option<String>where
Self::State: Debug,
fn format_step( &self, last_state: &Self::State, action: Self::Action ) -> Option<String>where Self::State: Debug,
source§fn properties(&self) -> Vec<Property<Self>>
fn properties(&self) -> Vec<Property<Self>>
source§fn within_boundary(&self, state: &Self::State) -> bool
fn within_boundary(&self, state: &Self::State) -> bool
source§fn next_steps(
&self,
last_state: &Self::State
) -> Vec<(Self::Action, Self::State)>
fn next_steps( &self, last_state: &Self::State ) -> Vec<(Self::Action, Self::State)>
source§fn next_states(&self, last_state: &Self::State) -> Vec<Self::State>
fn next_states(&self, last_state: &Self::State) -> Vec<Self::State>
Model::next_steps
and projecting out the states.