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>,
) -> Message
pub fn new( topic: impl Into<String>, payload: Vec<u8>, sender: impl Into<String>, ) -> Message
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<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Message, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Message
impl Serialize for Message
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more