Struct hid_io_protocol::HidIoPacketBuffer
source · #[repr(C)]pub struct HidIoPacketBuffer<const H: usize> {
pub ptype: HidIoPacketType,
pub id: HidIoCommandId,
pub max_len: u32,
pub data: Vec<u8, H>,
pub done: bool,
}
Expand description
HID-IO Packet Buffer Struct
Remarks
Used to store HID-IO data chunks. Will be chunked into individual packets on transmission.
Fields§
§ptype: HidIoPacketType
Type of packet (Continued is automatically set if needed)
id: HidIoCommandId
Packet Id
max_len: u32
Packet length for serialization (in bytes)
data: Vec<u8, H>
Payload data, chunking is done automatically by serializer
done: bool
Set False if buffer is not complete, True if it is
Implementations§
source§impl<const H: usize> HidIoPacketBuffer<H>
impl<const H: usize> HidIoPacketBuffer<H>
sourcepub fn new() -> HidIoPacketBuffer<H>
pub fn new() -> HidIoPacketBuffer<H>
sourcepub fn set(&mut self, buf: HidIoPacketBuffer<H>)
pub fn set(&mut self, buf: HidIoPacketBuffer<H>)
Set Data
sourcepub fn serialized_len(&self) -> u32
pub fn serialized_len(&self) -> u32
Serialized length of buffer Returns the currently computed serialized length of the buffer. Can change based on the struct fields.
sourcepub fn append_payload(&mut self, new_data: &[u8]) -> bool
pub fn append_payload(&mut self, new_data: &[u8]) -> bool
sourcepub fn decode_packet(
&mut self,
packet_data: &[u8]
) -> Result<u32, HidIoParseError>
pub fn decode_packet(
&mut self,
packet_data: &[u8]
) -> Result<u32, HidIoParseError>
sourcepub fn serialize_buffer<'a>(
&self,
data: &'a mut [u8]
) -> Result<&'a [u8], HidIoParseError>
pub fn serialize_buffer<'a>(
&self,
data: &'a mut [u8]
) -> Result<&'a [u8], HidIoParseError>
Serialize HidIoPacketBuffer
Remarks
Determine cont, width, upper_len and len fields According to this C-Struct:
struct HidIo_Packet {
HidIo_Packet_Type type:3;
uint8_t cont:1; // 0 - Only packet, 1 continued packet following
uint8_t id_width:1; // 0 - 16bits, 1 - 32bits
uint8_t reserved:1; // Reserved
uint8_t upper_len:2; // Upper 2 bits of length field (generally unused)
uint8_t len; // Lower 8 bits of length field
uint8_t data[0]; // Start of data payload (may start with Id)
};
Trait Implementations§
source§impl<const H: usize> Clone for HidIoPacketBuffer<H>
impl<const H: usize> Clone for HidIoPacketBuffer<H>
source§fn clone(&self) -> HidIoPacketBuffer<H>
fn clone(&self) -> HidIoPacketBuffer<H>
Returns a copy 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 more