Struct hid_io_protocol::HidIoPacketBuffer [−][src]
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]
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]
&mut self,
packet_data: &[u8]
) -> Result<u32, HidIoParseError>
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]
&mut self,
data: &'a mut [u8]
) -> Result<&'a [u8], HidIoParseError>
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]
fn clone(&self) -> HidIoPacketBuffer<H>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<H: Debug + ArrayLength<u8>> Debug for HidIoPacketBuffer<H>
[src]
impl<H> Default for HidIoPacketBuffer<H> where
H: ArrayLength<u8>,
[src]
H: ArrayLength<u8>,
impl<H: ArrayLength<u8>> Display for HidIoPacketBuffer<H>
[src]
impl<H: PartialEq + ArrayLength<u8>> PartialEq<HidIoPacketBuffer<H>> for HidIoPacketBuffer<H>
[src]
fn eq(&self, other: &HidIoPacketBuffer<H>) -> bool
[src]
fn ne(&self, other: &HidIoPacketBuffer<H>) -> bool
[src]
impl<H> Serialize for HidIoPacketBuffer<H> where
H: ArrayLength<u8>,
[src]
H: ArrayLength<u8>,
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
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,
<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,
<H as ArrayLength<u8>>::ArrayType: Unpin,
impl<H> UnwindSafe for HidIoPacketBuffer<H> where
<H as ArrayLength<u8>>::ArrayType: UnwindSafe,
<H as ArrayLength<u8>>::ArrayType: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,