[][src]Struct hid_io::protocol::hidio::HIDIOPacketBuffer

#[repr(C)]
pub struct HIDIOPacketBuffer {
    pub ptype: HIDIOPacketType,
    pub id: u32,
    pub max_len: u32,
    pub data: Vec<u8>,
    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: u32

Packet Id

max_len: u32

Packet length for serialization (in bytes)

data: Vec<u8>

Payload data, chunking is done automatically by serializer

done: bool

Set False if buffer is not complete, True if it is

Methods

impl HIDIOPacketBuffer[src]

pub fn new() -> HIDIOPacketBuffer[src]

Constructor for HIDIOPacketBuffer

Remarks

Initialize as blank

pub fn append_payload(&mut self, new_data: &mut Vec<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: &mut Vec<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(&mut self) -> Result<Vec<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 Clone for HIDIOPacketBuffer[src]

impl Default for HIDIOPacketBuffer[src]

impl PartialEq<HIDIOPacketBuffer> for HIDIOPacketBuffer[src]

impl Display for HIDIOPacketBuffer[src]

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

Display formatter for HIDIOPacketBuffer

impl Debug for HIDIOPacketBuffer[src]

impl Serialize for HIDIOPacketBuffer[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)
};

Auto Trait Implementations

impl Send for HIDIOPacketBuffer

impl Sync for HIDIOPacketBuffer

impl Unpin for HIDIOPacketBuffer

impl UnwindSafe for HIDIOPacketBuffer

impl RefUnwindSafe for HIDIOPacketBuffer

Blanket Implementations

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

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

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.

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

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]