AppChannelPacket

Struct AppChannelPacket 

Source
pub struct AppChannelPacket(/* private fields */);
Expand description

§App channel packet

This object wraps a Vec but can only be created for byte array of length <= APPCHANNEL_MTU.

The TryFrom trait is implemented for Vec<u8> and &[u8]. The From trait is implemented for fixed size array with compatible length. These traits are teh expected way to build a packet:

let a: AppChannelPacket = [1,2,3].into();
let b: AppChannelPacket = vec![1,2,3].try_into().unwrap();

And it protects agains building bad packets:

// This will panic!
let bad: AppChannelPacket = vec![0; 64].try_into().unwrap();

The traits also allows to go the other way:

let pk: AppChannelPacket = [1,2,3].into();
let data: Vec<u8> = pk.into();
assert_eq!(data, vec![1,2,3]);

Trait Implementations§

Source§

impl Debug for AppChannelPacket

Source§

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

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

impl From<[u8; 0]> for AppChannelPacket

Source§

fn from(v: [u8; 0]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 1]> for AppChannelPacket

Source§

fn from(v: [u8; 1]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 10]> for AppChannelPacket

Source§

fn from(v: [u8; 10]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 11]> for AppChannelPacket

Source§

fn from(v: [u8; 11]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 12]> for AppChannelPacket

Source§

fn from(v: [u8; 12]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 13]> for AppChannelPacket

Source§

fn from(v: [u8; 13]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 14]> for AppChannelPacket

Source§

fn from(v: [u8; 14]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 15]> for AppChannelPacket

Source§

fn from(v: [u8; 15]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 16]> for AppChannelPacket

Source§

fn from(v: [u8; 16]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 17]> for AppChannelPacket

Source§

fn from(v: [u8; 17]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 18]> for AppChannelPacket

Source§

fn from(v: [u8; 18]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 19]> for AppChannelPacket

Source§

fn from(v: [u8; 19]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 2]> for AppChannelPacket

Source§

fn from(v: [u8; 2]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 20]> for AppChannelPacket

Source§

fn from(v: [u8; 20]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 21]> for AppChannelPacket

Source§

fn from(v: [u8; 21]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 22]> for AppChannelPacket

Source§

fn from(v: [u8; 22]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 23]> for AppChannelPacket

Source§

fn from(v: [u8; 23]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 24]> for AppChannelPacket

Source§

fn from(v: [u8; 24]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 25]> for AppChannelPacket

Source§

fn from(v: [u8; 25]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 26]> for AppChannelPacket

Source§

fn from(v: [u8; 26]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 27]> for AppChannelPacket

Source§

fn from(v: [u8; 27]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 28]> for AppChannelPacket

Source§

fn from(v: [u8; 28]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 29]> for AppChannelPacket

Source§

fn from(v: [u8; 29]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 3]> for AppChannelPacket

Source§

fn from(v: [u8; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 30]> for AppChannelPacket

Source§

fn from(v: [u8; 30]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 4]> for AppChannelPacket

Source§

fn from(v: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 5]> for AppChannelPacket

Source§

fn from(v: [u8; 5]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 6]> for AppChannelPacket

Source§

fn from(v: [u8; 6]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 7]> for AppChannelPacket

Source§

fn from(v: [u8; 7]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 8]> for AppChannelPacket

Source§

fn from(v: [u8; 8]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 9]> for AppChannelPacket

Source§

fn from(v: [u8; 9]) -> Self

Converts to this type from the input type.
Source§

impl From<AppChannelPacket> for Vec<u8>

Source§

fn from(pk: AppChannelPacket) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for AppChannelPacket

Source§

fn eq(&self, other: &AppChannelPacket) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&[u8]> for AppChannelPacket

Source§

type Error = Error

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

fn try_from(value: &[u8]) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Vec<u8>> for AppChannelPacket

Source§

type Error = Error

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

fn try_from(value: Vec<u8>) -> Result<Self>

Performs the conversion.
Source§

impl Eq for AppChannelPacket

Source§

impl StructuralPartialEq for AppChannelPacket

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.