Trait stateright::Model
source · pub trait Model: Sized {
type State;
type Action;
// Required methods
fn init_states(&self) -> Vec<Self::State>;
fn actions(&self, state: &Self::State, actions: &mut Vec<Self::Action>);
fn next_state(
&self,
last_state: &Self::State,
action: Self::Action
) -> Option<Self::State>;
// Provided methods
fn format_action(&self, action: &Self::Action) -> String
where Self::Action: Debug { ... }
fn format_step(
&self,
last_state: &Self::State,
action: Self::Action
) -> Option<String>
where Self::State: Debug { ... }
fn as_svg(&self, _path: Path<Self::State, Self::Action>) -> Option<String> { ... }
fn next_steps(
&self,
last_state: &Self::State
) -> Vec<(Self::Action, Self::State)> { ... }
fn next_states(&self, last_state: &Self::State) -> Vec<Self::State> { ... }
fn properties(&self) -> Vec<Property<Self>> { ... }
fn property(&self, name: &'static str) -> Property<Self> { ... }
fn within_boundary(&self, _state: &Self::State) -> bool { ... }
fn checker(self) -> CheckerBuilder<Self>
where Self: Send + Sync + 'static,
Self::State: Hash + Send + Sync { ... }
}
Expand description
This is the primary abstraction for Stateright. Implementations model a
nondeterministic system’s evolution. If you are using Stateright’s actor framework,
then you do not need to implement this interface and can instead leverage
actor::Actor
and actor::ActorModel
.
You can instantiate a model CheckerBuilder
by calling Model::checker
.
Required Associated Types§
Required Methods§
sourcefn init_states(&self) -> Vec<Self::State>
fn init_states(&self) -> Vec<Self::State>
Returns the initial possible states.
Provided Methods§
sourcefn format_action(&self, action: &Self::Action) -> String
fn format_action(&self, action: &Self::Action) -> String
Converts an action of this model to a more intuitive representation (e.g. for Explorer).
sourcefn format_step(
&self,
last_state: &Self::State,
action: Self::Action
) -> Option<String>
fn format_step( &self, last_state: &Self::State, action: Self::Action ) -> Option<String>
Converts a step of this model to a more intuitive representation (e.g. for Explorer).
sourcefn 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)>
Indicates the steps (action-state pairs) that follow a particular state.
sourcefn next_states(&self, last_state: &Self::State) -> Vec<Self::State>
fn next_states(&self, last_state: &Self::State) -> Vec<Self::State>
Indicates the states that follow a particular state. Slightly more efficient than calling
Model::next_steps
and projecting out the states.
sourcefn properties(&self) -> Vec<Property<Self>>
fn properties(&self) -> Vec<Property<Self>>
Generates the expected properties for this model.
sourcefn property(&self, name: &'static str) -> Property<Self>
fn property(&self, name: &'static str) -> Property<Self>
Looks up a property by name. Panics if the property does not exist.
sourcefn within_boundary(&self, _state: &Self::State) -> bool
fn within_boundary(&self, _state: &Self::State) -> bool
Indicates whether a state is within the state space that should be model checked.
sourcefn checker(self) -> CheckerBuilder<Self>
fn checker(self) -> CheckerBuilder<Self>
Instantiates a CheckerBuilder
for this model.