Struct fizyr_rpc::MessageHeader
source · #[repr(C)]pub struct MessageHeader {
pub message_type: MessageType,
pub request_id: u32,
pub service_id: i32,
}
Expand description
A message header.
Fields§
§message_type: MessageType
The message type.
request_id: u32
The request that the message is part of.
Unused for stream messages.
service_id: i32
The service that the message is for.
For request messages, this indicates the service being requested.
For response messages this indicates success or failure.
For update messages this indicates the type of update.
Implementations§
source§impl MessageHeader
impl MessageHeader
sourcepub fn response(request_id: u32, service_id: i32) -> Self
pub fn response(request_id: u32, service_id: i32) -> Self
Create a new response message header.
sourcepub fn error_response(request_id: u32) -> Self
pub fn error_response(request_id: u32) -> Self
Create a new error response message header.
sourcepub fn requester_update(request_id: u32, service_id: i32) -> Self
pub fn requester_update(request_id: u32, service_id: i32) -> Self
Create a new requester update message header.
sourcepub fn responder_update(request_id: u32, service_id: i32) -> Self
pub fn responder_update(request_id: u32, service_id: i32) -> Self
Create a new responder update message header.
sourcepub fn decode(buffer: &[u8], endian: Endian) -> Result<Self, Error>
pub fn decode(buffer: &[u8], endian: Endian) -> Result<Self, Error>
Decode a message header from a byte slice using the given endianness for the header fields.
The byte slice should NOT contain the message size.
Panic
This function panics if the buffer does not contain a full header.
sourcepub fn encode(&self, buffer: &mut [u8], endian: Endian)
pub fn encode(&self, buffer: &mut [u8], endian: Endian)
Encode a message header into a byte slice using the given endianness for the header fields.
This will NOT add a message size (which would be impossible even if we wanted to).
Panic
This function panics if the buffer is not large enough to hold a full header.
Trait Implementations§
source§impl Clone for MessageHeader
impl Clone for MessageHeader
source§fn clone(&self) -> MessageHeader
fn clone(&self) -> MessageHeader
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MessageHeader
impl Debug for MessageHeader
source§impl Hash for MessageHeader
impl Hash for MessageHeader
source§impl Ord for MessageHeader
impl Ord for MessageHeader
source§fn cmp(&self, other: &MessageHeader) -> Ordering
fn cmp(&self, other: &MessageHeader) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for MessageHeader
impl PartialEq for MessageHeader
source§fn eq(&self, other: &MessageHeader) -> bool
fn eq(&self, other: &MessageHeader) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for MessageHeader
impl PartialOrd for MessageHeader
source§fn partial_cmp(&self, other: &MessageHeader) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageHeader) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more