pub struct Message {
pub id: String,
pub topic: String,
pub payload: Vec<u8>,
pub sender: String,
pub metadata: HashMap<String, String>,
pub created_at: i64,
}Expand description
A message for inter-agent communication.
Messages carry binary payloads between agents in a mesh.
§Example
use ceylon_core::Message;
// Create a message
let msg = Message::new("greeting", b"Hello!".to_vec(), "sender-agent");
// Access message properties
println!("Topic: {}", msg.topic);
println!("From: {}", msg.sender);Fields§
§id: StringUnique message identifier (auto-generated UUID).
topic: StringMessage topic/type for routing or categorization.
payload: Vec<u8>Binary payload data.
sender: StringName of the sending agent.
metadata: HashMap<String, String>Arbitrary metadata key-value pairs.
created_at: i64Creation timestamp in microseconds since epoch.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
topic: impl Into<String>,
payload: Vec<u8>,
sender: impl Into<String>,
) -> Self
pub fn new( topic: impl Into<String>, payload: Vec<u8>, sender: impl Into<String>, ) -> Self
Create a new message.
§Arguments
topic- Message topic for routingpayload- Binary payloadsender- Name of the sending agent
Sourcepub fn correlation_id(&self) -> Option<String>
pub fn correlation_id(&self) -> Option<String>
Get the correlation ID for request/response tracking.
Sourcepub fn set_correlation_id(&mut self, id: &str)
pub fn set_correlation_id(&mut self, id: &str)
Set a correlation ID for request/response tracking.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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