#[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

Constructor for HidIoPacketBuffer

Remarks

Initialize as blank

Clear Data Sets done to false and resizes payload to 0

Set Data

Serialized length of buffer Returns the currently computed serialized length of the buffer. Can change based on the struct fields.

Append payload data

Arguments
  • new_data - Vector of bytes
Remarks

Appends payload to HidIoPacketBuffer.

Append packet stream Returns the number of bytes used.

Arguments
  • packet_data - Vector of bytes of packet data
Remarks

Does packet decoding on the fly. Will set done parameter if this is the last packet.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Display formatter for HidIoPacketBuffer

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.