ResponsePacket

Struct ResponsePacket 

Source
pub struct ResponsePacket<const N: usize = 256> { /* private fields */ }

Implementations§

Source§

impl<const N: usize> ResponsePacket<N>

Source

pub const fn new() -> Self

Source

pub fn from_reader(reader: &mut impl ReadPacket) -> Result<Self>

Source

pub fn from_slice(slice: &[u8]) -> Self

Initialize a struct from a slice.

§Panics

If the slice length is less than 4 and more than N. The slice can’t be less than 4 because the packet is always has at least 4 bytes.

Trait Implementations§

Source§

impl<const N: usize> AsMut<[u8]> for ResponsePacket<N>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<const N: usize> AsRef<[u8]> for ResponsePacket<N>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<const N: usize> Clone for ResponsePacket<N>

Source§

fn clone(&self) -> ResponsePacket<N>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for ResponsePacket<N>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for ResponsePacket<N>

Source§

fn default() -> Self

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

impl<const N: usize> Packet for ResponsePacket<N>

Source§

const SIZE_INDEX: usize = 2usize

Source§

const DATA_BEGIN_INDEX: usize = 4usize

Source§

const DESTINATION_INDEX: usize = 1usize

Source§

fn len_of_packet(&self) -> usize

Source§

fn as_slice(&self) -> &[u8]

Returns a slice of the packet until SUM byte.
Source§

fn as_mut_slice(&mut self) -> &mut [u8]

Returns a mutable slice of the packet until SUM byte.
Source§

fn sync(&self) -> u8

Returns a first byte in the slice.
Source§

fn set_sync(&mut self) -> &mut Self

Source§

fn size(&self) -> u8

Returns a SIZE byte at Packet::SIZE_INDEX
Source§

fn set_size(&mut self, size: u8) -> &mut Self

Sets a size byte at Packet::SIZE_INDEX. Read more
Source§

fn dest(&self) -> u8

Returns a destination byte at Packet::DESTINATION_INDEX.
Source§

fn set_dest(&mut self, dest: u8) -> &mut Self

Sets a destination byte at Packet::DESTINATION_INDEX and calculates a new checksum.
Source§

fn data(&self) -> &[u8]

Returns a slice of the packet data.
Source§

fn set_data(&mut self, data: &[u8]) -> &mut Self

Sets the packet data. Read more
Source§

fn calculate_checksum(&mut self) -> &mut Self

Calculates checksum. Read more
Source§

fn checksum(&self) -> u8

Returns a checksum.
Source§

fn set_checksum(&mut self, checksum: u8) -> &mut Self

Sets a checksum in the end of the packet. Read more
Source§

impl<const N: usize> ReportField for ResponsePacket<N>

Source§

const REPORT_INDEX: usize = 3usize

Source§

fn report(&self) -> Report

Returns a report code.
Source§

fn report_raw(&self) -> u8

Source§

fn set_report(&mut self, report: impl Into<u8>) -> &mut Self

Sets a report code.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for ResponsePacket<N>

§

impl<const N: usize> RefUnwindSafe for ResponsePacket<N>

§

impl<const N: usize> Send for ResponsePacket<N>

§

impl<const N: usize> Sync for ResponsePacket<N>

§

impl<const N: usize> Unpin for ResponsePacket<N>

§

impl<const N: usize> UnwindSafe for ResponsePacket<N>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.