Struct hid_io_protocol::HidIoPacketBuffer[][src]

#[repr(C)]pub struct HidIoPacketBuffer<H: ArrayLength<u8>> {
    pub ptype: HidIoPacketType,
    pub id: HidIoCommandId,
    pub max_len: u32,
    pub data: Vec<u8, H>,
    pub done: bool,
}

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

impl<H: ArrayLength<u8>> HidIoPacketBuffer<H>[src]

pub fn new() -> HidIoPacketBuffer<H>[src]

Constructor for HidIoPacketBuffer

Remarks

Initialize as blank

pub fn clear(&mut self)[src]

Clear Data Sets done to false and resizes payload to 0

pub fn set(&mut self, buf: HidIoPacketBuffer<H>)[src]

Set Data

pub fn serialized_len(&self) -> u32[src]

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

pub fn append_payload(&mut self, new_data: &[u8]) -> bool[src]

Append payload data

Arguments

  • new_data - Vector of bytes

Remarks

Appends payload to HidIoPacketBuffer.

pub fn decode_packet(
    &mut self,
    packet_data: &[u8]
) -> Result<u32, HidIoParseError>
[src]

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.

pub fn serialize_buffer<'a>(
    &mut self,
    data: &'a mut [u8]
) -> Result<&'a [u8], HidIoParseError>
[src]

Serialize HidIoPacketBuffer

Remarks

Provides a raw data vector to the serialized data. Removes some of the header that Serialize from serde prepends.

Trait Implementations

impl<H: Clone + ArrayLength<u8>> Clone for HidIoPacketBuffer<H>[src]

impl<H: Debug + ArrayLength<u8>> Debug for HidIoPacketBuffer<H>[src]

impl<H> Default for HidIoPacketBuffer<H> where
    H: ArrayLength<u8>, 
[src]

impl<H: ArrayLength<u8>> Display for HidIoPacketBuffer<H>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Display formatter for HidIoPacketBuffer

impl<H: PartialEq + ArrayLength<u8>> PartialEq<HidIoPacketBuffer<H>> for HidIoPacketBuffer<H>[src]

impl<H> Serialize for HidIoPacketBuffer<H> where
    H: ArrayLength<u8>, 
[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serializer for 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)
};

impl<H: ArrayLength<u8>> StructuralPartialEq for HidIoPacketBuffer<H>[src]

Auto Trait Implementations

impl<H> RefUnwindSafe for HidIoPacketBuffer<H> where
    <H as ArrayLength<u8>>::ArrayType: RefUnwindSafe

impl<H> Send for HidIoPacketBuffer<H>

impl<H> Sync for HidIoPacketBuffer<H>

impl<H> Unpin for HidIoPacketBuffer<H> where
    <H as ArrayLength<u8>>::ArrayType: Unpin

impl<H> UnwindSafe for HidIoPacketBuffer<H> where
    <H as ArrayLength<u8>>::ArrayType: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.