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§
Required Methods§
Sourcefn act(&mut self, now: u64, outbox: &mut Vec<Self::Message>)
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.
Sourcefn receive(
&mut self,
now: u64,
message: &Self::Message,
outbox: &mut Vec<Self::Message>,
)
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.
Sourcefn is_settled(team: &[Self], in_flight: &[&Self::Message]) -> bool
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".