Skip to main content

ActorModel

Struct ActorModel 

Source
pub struct ActorModel<A, C = (), H = ()>
where A: Actor, A::Msg: Ord, A::Timer: Ord, 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 Actors 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, A::Msg: Ord, A::Timer: Ord, H: Clone + Debug + Hash,

Source

pub fn new(cfg: C, init_history: H) -> ActorModel<A, C, H>

Initializes an ActorModel with a specified configuration and history.

Source

pub fn actor(self, actor: A) -> Self

Adds another Actor to this model.

Source

pub fn actors(self, actors: impl IntoIterator<Item = A>) -> Self

Adds multiple Actors to this model.

Source

pub fn init_network(self, init_network: Network<A::Msg>) -> Self

Defines the initial network.

Source

pub fn lossy_network(self, lossy_network: LossyNetwork) -> Self

Defines whether the network loses messages or not.

Source

pub fn max_crashes(self, max_crashes: usize) -> Self

Specifies the maximum number of actors that can be contemporarily crashed

Source

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.

Source

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.

Source

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.

Source

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, A::Msg: Ord + Clone, A::Timer: Ord, H: Clone + Debug + Hash + Clone,

Source§

fn clone(&self) -> ActorModel<A, C, H>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A, C, H> Model for ActorModel<A, C, H>
where A: Actor, A::Msg: Ord, A::Timer: Ord, H: Clone + Debug + Hash,

Source§

fn as_svg(&self, path: Path<Self::State, Self::Action>) -> Option<String>

Draws a sequence diagram for the actor system.

Source§

type State = ActorModelState<A, H>

The type of state upon which this model operates.
Source§

type Action = ActorModelAction<<A as Actor>::Msg, <A as Actor>::Timer, <A as Actor>::Random>

The type of action that transitions between states.
Source§

fn init_states(&self) -> Vec<Self::State>

Returns the initial possible states. Read more
Source§

fn actions(&self, state: &Self::State, actions: &mut Vec<Self::Action>)

Collects the subsequent possible actions based on a previous state. Read more
Source§

fn next_state( &self, last_sys_state: &Self::State, action: Self::Action, ) -> Option<Self::State>

Converts a previous state and action to a resulting state. None indicates that the action does not change the state.
Source§

fn format_action(&self, action: &Self::Action) -> String

Converts an action of this model to a more intuitive representation (e.g. for Explorer).
Source§

fn format_step( &self, last_state: &Self::State, action: Self::Action, ) -> Option<String>
where Self::State: Debug,

Converts a step of this model to a more intuitive representation (e.g. for Explorer).
Source§

fn properties(&self) -> Vec<Property<Self>>

Generates the expected properties for this model.
Source§

fn within_boundary(&self, state: &Self::State) -> bool

Indicates whether a state is within the state space that should be model checked.
Source§

fn next_steps( &self, last_state: &Self::State, ) -> Vec<(Self::Action, Self::State)>

Indicates the steps (action-state pairs) that follow a particular state.
Source§

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.
Source§

fn property(&self, name: &'static str) -> Property<Self>

Looks up a property by name. Panics if the property does not exist.
Source§

fn checker(self) -> CheckerBuilder<Self>
where Self: Send + Sync + 'static, Self::State: Hash + Send + Sync,

Instantiates a CheckerBuilder for this model.

Auto Trait Implementations§

§

impl<A, C, H> Freeze for ActorModel<A, C, H>
where C: Freeze, H: Freeze, <A as Actor>::Msg: Freeze,

§

impl<A, C, H> RefUnwindSafe for ActorModel<A, C, H>

§

impl<A, C, H> Send for ActorModel<A, C, H>
where C: Send, H: Send, A: Send, <A as Actor>::Msg: Send,

§

impl<A, C, H> Sync for ActorModel<A, C, H>
where C: Sync, H: Sync, A: Sync, <A as Actor>::Msg: Sync,

§

impl<A, C, H> Unpin for ActorModel<A, C, H>
where C: Unpin, H: Unpin, A: Unpin, <A as Actor>::Msg: Unpin,

§

impl<A, C, H> UnsafeUnpin for ActorModel<A, C, H>
where C: UnsafeUnpin, H: UnsafeUnpin, <A as Actor>::Msg: UnsafeUnpin,

§

impl<A, C, H> UnwindSafe for ActorModel<A, C, H>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V