Struct kiibohd_hid_io::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 moresource§impl<const H: usize> Debug for HidIoPacketBuffer<H>
impl<const H: usize> Debug for HidIoPacketBuffer<H>
source§impl<const H: usize> Default for HidIoPacketBuffer<H>
impl<const H: usize> Default for HidIoPacketBuffer<H>
source§fn default() -> HidIoPacketBuffer<H>
fn default() -> HidIoPacketBuffer<H>
Returns the “default value” for a type. Read more
source§impl<const H: usize> Display for HidIoPacketBuffer<H>
impl<const H: usize> Display for HidIoPacketBuffer<H>
source§impl<const H: usize> PartialEq<HidIoPacketBuffer<H>> for HidIoPacketBuffer<H>
impl<const H: usize> PartialEq<HidIoPacketBuffer<H>> for HidIoPacketBuffer<H>
source§fn eq(&self, other: &HidIoPacketBuffer<H>) -> bool
fn eq(&self, other: &HidIoPacketBuffer<H>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<const H: usize> Eq for HidIoPacketBuffer<H>
impl<const H: usize> StructuralEq for HidIoPacketBuffer<H>
impl<const H: usize> StructuralPartialEq for HidIoPacketBuffer<H>
Auto Trait Implementations§
impl<const H: usize> RefUnwindSafe for HidIoPacketBuffer<H>
impl<const H: usize> Send for HidIoPacketBuffer<H>
impl<const H: usize> Sync for HidIoPacketBuffer<H>
impl<const H: usize> Unpin for HidIoPacketBuffer<H>
impl<const H: usize> UnwindSafe for HidIoPacketBuffer<H>
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