AgentState

Trait AgentState 

Source
pub trait AgentState<State: DataLike, Payload: DataLike> {
    // Required method
    fn reaction(
        &self,
        instance: usize,
        payload: &Payload,
    ) -> Reaction<State, Payload>;

    // Provided methods
    fn activity(&self, _instance: usize) -> Activity<Payload> { ... }
    fn is_deferring(&self, _instance: usize) -> bool { ... }
    fn invalid_because(&self, _instance: usize) -> Option<&'static str> { ... }
    fn max_in_flight_messages(&self, _instance: usize) -> Option<usize> { ... }
}
Expand description

A trait for a single agent state.

Required Methods§

Source

fn reaction( &self, instance: usize, payload: &Payload, ) -> Reaction<State, Payload>

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

Provided Methods§

Source

fn activity(&self, _instance: usize) -> Activity<Payload>

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

Source

fn is_deferring(&self, _instance: usize) -> bool

Whether any agent in this state is deferring messages.

Source

fn invalid_because(&self, _instance: usize) -> Option<&'static str>

If this object is invalid, return why.

Source

fn max_in_flight_messages(&self, _instance: usize) -> Option<usize>

The maximal number of messages sent by this agent which may be in-flight when it is in this state.

Implementors§