Skip to main content

Participant

Trait Participant 

Source
pub trait Participant: Sized {
    type Message;

    // Required methods
    fn id(&self) -> AgentId;
    fn bundle(&self) -> &Bundle<TaskId>;
    fn act(&mut self, now: u64, outbox: &mut Vec<Self::Message>);
    fn receive(
        &mut self,
        now: u64,
        message: &Self::Message,
        outbox: &mut Vec<Self::Message>,
    );
    fn is_settled(team: &[Self], in_flight: &[&Self::Message]) -> bool;
}
Expand description

An agent that a Simulation can run: it works in rounds, broadcasts messages, and handles the messages that reach it.

cbba::Agent implements it; so can other consensus protocols.

Required Associated Types§

Source

type Message

What the agent broadcasts.

Required Methods§

Source

fn id(&self) -> AgentId

The agent’s identifier.

Source

fn bundle(&self) -> &Bundle<TaskId>

The tasks the agent holds now.

Source

fn act(&mut self, now: u64, outbox: &mut Vec<Self::Message>)

One round of the agent’s own work at tick now, such as its bundle phase; pushes what it broadcasts onto outbox.

Source

fn receive( &mut self, now: u64, message: &Self::Message, outbox: &mut Vec<Self::Message>, )

Handles message, arriving at tick now; pushes what the agent broadcasts in response onto outbox.

Source

fn is_settled(team: &[Self], in_flight: &[&Self::Message]) -> bool

Whether team has settled, with in_flight still on its way: the agents agree on a conflict-free assignment that nothing in flight and no further round can change.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<R: Route> Participant for TimedAgent<R>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::ccbba::Agent<V>

Source§

impl<V: Valuation<TaskId>> Participant for task_allocation::cbba::Agent<V>