pub struct AppChannelPacket(/* private fields */);Expand description
§App channel packet
This object wraps a Vec
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
impl Debug for AppChannelPacket
Source§impl From<AppChannelPacket> for Vec<u8>
impl From<AppChannelPacket> for Vec<u8>
Source§fn from(pk: AppChannelPacket) -> Self
fn from(pk: AppChannelPacket) -> Self
Converts to this type from the input type.
Source§impl PartialEq for AppChannelPacket
impl PartialEq for AppChannelPacket
Source§impl TryFrom<&[u8]> for AppChannelPacket
impl TryFrom<&[u8]> for AppChannelPacket
impl Eq for AppChannelPacket
impl StructuralPartialEq for AppChannelPacket
Auto Trait Implementations§
impl Freeze for AppChannelPacket
impl RefUnwindSafe for AppChannelPacket
impl Send for AppChannelPacket
impl Sync for AppChannelPacket
impl Unpin for AppChannelPacket
impl UnwindSafe for AppChannelPacket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more