Struct AgentTypeData

Source
pub struct AgentTypeData<State: DataLike, StateId: IndexLike, Payload: DataLike> { /* private fields */ }
Expand description

The data we need to implement an agent type.

This should be placed in a Singleton to allow the agent states to get services from it.

Implementations§

Source§

impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentTypeData<State, StateId, Payload>

Source

pub fn new( name: &'static str, instances: Instances, prev_agent_type: Option<Rc<dyn AgentType<StateId, Payload>>>, ) -> Self

Create new agent type data with the specified name and number of instances.

Source

pub fn set_order(&mut self, instance: usize, order: usize)

Set the horizontal order of an instance of the agent in a sequence diagram.

Source

pub fn get_state(&self, state_id: StateId) -> State

Access the actual state by its identifier.

Trait Implementations§

Source§

impl<State: DataLike, StateId: IndexLike, Payload: DataLike> AgentInstances<StateId, Payload> for AgentTypeData<State, StateId, Payload>

Source§

fn prev_agent_type(&self) -> Option<Rc<dyn AgentType<StateId, Payload>>>

Return the previous agent type in the chain, if any.
Source§

fn first_index(&self) -> usize

The index of the first agent of this type.
Source§

fn next_index(&self) -> usize

The next index after the last agent of this type.
Source§

fn is_singleton(&self) -> bool

Whether this type only has a single instance. Read more
Source§

fn instances_count(&self) -> usize

The number of agents of this type that will be used in the system.
Source§

fn instance_order(&self, instance: usize) -> usize

The order of the agent (for sequence diagrams).
Source§

fn display_state(&self, state_id: StateId) -> Rc<String>

Display the state. Read more
Source§

fn terse_id(&self, state_id: StateId) -> StateId

Convert the full state identifier to the terse state identifier.
Source§

fn display_terse(&self, terse_id: StateId) -> String

Return the name of the terse state (just the state name).
Source§

impl<State: DataLike + AgentState<State, Payload>, StateId: IndexLike, Payload: DataLike> AgentType<StateId, Payload> for AgentTypeData<State, StateId, Payload>

Source§

fn reaction( &self, instance: usize, state_ids: &[StateId], payload: &Payload, ) -> Reaction<StateId, Payload>

Return the actions that may be taken by an agent instance with some state when receiving a payload.
Source§

fn activity(&self, instance: usize, state_ids: &[StateId]) -> Activity<Payload>

Return the actions that may be taken by an agent with some state when time passes.
Source§

fn state_is_deferring(&self, instance: usize, state_ids: &[StateId]) -> bool

Whether any agent in the state is deferring messages.
Source§

fn state_invalid_because( &self, instance: usize, state_ids: &[StateId], ) -> Option<&'static str>

Return a reason that a state is invalid (unless it is valid).
Source§

fn state_max_in_flight_messages( &self, instance: usize, state_ids: &[StateId], ) -> Option<usize>

The maximal number of messages sent by an agent which may be in-flight when it is in the state.
Source§

fn states_count(&self) -> usize

The total number of states seen so far.
Source§

fn compute_terse(&self)

Compute mapping from full states to terse states (name only).
Source§

impl<State: DataLike, StateId: IndexLike, Payload: DataLike> Name for AgentTypeData<State, StateId, Payload>

Source§

fn name(&self) -> String

Source§

impl<State: DataLike, StateId: IndexLike, Payload: DataLike> PartType<State, StateId> for AgentTypeData<State, StateId, Payload>

Source§

fn part_state_by_id(&self, state_id: StateId) -> State

Access the part state by the state identifier.
Source§

fn part_first_index(&self) -> usize

The index of the first agent of this type.
Source§

fn parts_count(&self) -> usize

The number of agent instances of this type.

Auto Trait Implementations§

§

impl<State, StateId, Payload> !Freeze for AgentTypeData<State, StateId, Payload>

§

impl<State, StateId, Payload> !RefUnwindSafe for AgentTypeData<State, StateId, Payload>

§

impl<State, StateId, Payload> !Send for AgentTypeData<State, StateId, Payload>

§

impl<State, StateId, Payload> !Sync for AgentTypeData<State, StateId, Payload>

§

impl<State, StateId, Payload> Unpin for AgentTypeData<State, StateId, Payload>
where Payload: Unpin, StateId: Unpin, State: Unpin,

§

impl<State, StateId, Payload> !UnwindSafe for AgentTypeData<State, StateId, Payload>

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> 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, 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.