pub struct OdinMessage {
pub id: String,
pub message_type: MessageType,
pub source_node: String,
pub target_node: String,
pub content: String,
pub priority: MessagePriority,
pub timestamp: u64,
pub metadata: HashMap<String, String>,
pub sequence: u64,
pub checksum: Option<String>,
}Expand description
ODIN Protocol message
Fields§
§id: StringUnique message identifier
message_type: MessageTypeMessage type
source_node: StringSource node identifier
target_node: StringTarget node identifier
content: StringMessage content
priority: MessagePriorityMessage priority
timestamp: u64Timestamp when message was created
metadata: HashMap<String, String>Message metadata
sequence: u64Message sequence number
checksum: Option<String>Checksum for integrity verification
Implementations§
Source§impl OdinMessage
impl OdinMessage
Sourcepub fn new(
message_type: MessageType,
source_node: &str,
target_node: &str,
content: &str,
priority: MessagePriority,
) -> Self
pub fn new( message_type: MessageType, source_node: &str, target_node: &str, content: &str, priority: MessagePriority, ) -> Self
Create a new ODIN message
Sourcepub fn with_metadata(self, key: String, value: String) -> Self
pub fn with_metadata(self, key: String, value: String) -> Self
Add metadata to the message
Sourcepub fn with_sequence(self, sequence: u64) -> Self
pub fn with_sequence(self, sequence: u64) -> Self
Set sequence number
Sourcepub fn with_checksum(self) -> Self
pub fn with_checksum(self) -> Self
Calculate and set checksum
Sourcepub fn is_expired(&self, ttl_seconds: u64) -> bool
pub fn is_expired(&self, ttl_seconds: u64) -> bool
Check if message is expired based on TTL
Sourcepub fn create_reply(&self, content: &str, priority: MessagePriority) -> Self
pub fn create_reply(&self, content: &str, priority: MessagePriority) -> Self
Create a reply message
Sourcepub fn create_ack(&self) -> Self
pub fn create_ack(&self) -> Self
Create an acknowledgment message
Trait Implementations§
Source§impl Clone for OdinMessage
impl Clone for OdinMessage
Source§fn clone(&self) -> OdinMessage
fn clone(&self) -> OdinMessage
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OdinMessage
impl Debug for OdinMessage
Source§impl<'de> Deserialize<'de> for OdinMessage
impl<'de> Deserialize<'de> for OdinMessage
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 OdinMessage
impl RefUnwindSafe for OdinMessage
impl Send for OdinMessage
impl Sync for OdinMessage
impl Unpin for OdinMessage
impl UnsafeUnpin for OdinMessage
impl UnwindSafe for OdinMessage
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