pub struct ForestMessage {
pub from: AgentId,
pub to: Option<AgentId>,
pub content: String,
pub metadata: HashMap<String, String>,
pub timestamp: DateTime<Utc>,
}Expand description
A message sent between agents in the forest.
Fields§
§from: AgentIdThe ID of the sender agent.
to: Option<AgentId>The ID of the recipient agent (None for broadcast).
content: StringThe message content.
metadata: HashMap<String, String>Optional metadata associated with the message.
timestamp: DateTime<Utc>Timestamp of the message.
Implementations§
Source§impl ForestMessage
impl ForestMessage
Sourcepub fn new(from: AgentId, to: Option<AgentId>, content: String) -> Self
pub fn new(from: AgentId, to: Option<AgentId>, content: String) -> Self
Creates a new forest message.
Sourcepub fn broadcast(from: AgentId, content: String) -> Self
pub fn broadcast(from: AgentId, content: String) -> Self
Creates a broadcast message to all agents.
Sourcepub fn with_metadata(self, key: String, value: String) -> Self
pub fn with_metadata(self, key: String, value: String) -> Self
Adds metadata to the message.
Trait Implementations§
Source§impl Clone for ForestMessage
impl Clone for ForestMessage
Source§fn clone(&self) -> ForestMessage
fn clone(&self) -> ForestMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ForestMessage
impl RefUnwindSafe for ForestMessage
impl Send for ForestMessage
impl Sync for ForestMessage
impl Unpin for ForestMessage
impl UnwindSafe for ForestMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more