pub trait Message: Clone + Send + Sync {
// Required method
fn tick() -> Self;
}
Expand description
A message that Agent
s and Game
s will be passing around.
The relevant agents and games will be taking this as a generic parameter, not using it as a trait object, and you
should do the same. Usually you’ll implement this in an enum. If you want a trait object, use Message
as a
supertrait for yours.
This trait requires Clone
, Send
, and Sync
, to ensure it can be properly shared across all threads.
Required Methods§
sourcefn tick() -> Self
fn tick() -> Self
The message to send agents when there aren’t any other messages queued for processing, to ensure every awake agent processes at least one message per round. Will not be sent if there are any other messages!
This method should be as simple and fast as possible, ideally just returning a constant value.
Object Safety§
This trait is not object safe.