pub struct MessageHeader {
pub version: u8,
pub message_type: MessageType,
pub priority: Priority,
pub sequence: u32,
pub timestamp: u32,
pub context_version: u32,
}Expand description
Message header (13 bytes total)
Fields§
§version: u8Protocol version (2 bits in header byte)
message_type: MessageTypeMessage type (3 bits in header byte)
priority: PriorityPriority level (3 bits in header byte)
sequence: u32Sequence number
timestamp: u32Timestamp
context_version: u32Context version used for encoding
Implementations§
Source§impl MessageHeader
impl MessageHeader
Sourcepub fn new(message_type: MessageType, priority: Priority) -> Self
pub fn new(message_type: MessageType, priority: Priority) -> Self
Create a new header with default values
Sourcepub fn encode_header_byte(&self) -> u8
pub fn encode_header_byte(&self) -> u8
Encode the header byte (version + type + priority)
Sourcepub fn decode_header_byte(
byte: u8,
) -> (u8, Option<MessageType>, Option<Priority>)
pub fn decode_header_byte( byte: u8, ) -> (u8, Option<MessageType>, Option<Priority>)
Decode the header byte
Sourcepub fn from_bytes(bytes: &[u8]) -> Option<Self>
pub fn from_bytes(bytes: &[u8]) -> Option<Self>
Deserialize header from bytes
Trait Implementations§
Source§impl Clone for MessageHeader
impl Clone for MessageHeader
Source§fn clone(&self) -> MessageHeader
fn clone(&self) -> MessageHeader
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 moreSource§impl Debug for MessageHeader
impl Debug for MessageHeader
Source§impl Default for MessageHeader
impl Default for MessageHeader
Source§impl PartialEq for MessageHeader
impl PartialEq for MessageHeader
impl Eq for MessageHeader
impl StructuralPartialEq for MessageHeader
Auto Trait Implementations§
impl Freeze for MessageHeader
impl RefUnwindSafe for MessageHeader
impl Send for MessageHeader
impl Sync for MessageHeader
impl Unpin for MessageHeader
impl UnsafeUnpin for MessageHeader
impl UnwindSafe for MessageHeader
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