pub struct RawPacket {
pub flags: PacketFlags,
pub hops: u8,
pub transport_id: Option<[u8; 16]>,
pub destination_hash: [u8; 16],
pub context: u8,
pub data: Vec<u8>,
pub raw: Vec<u8>,
pub packet_hash: [u8; 32],
}Fields§
§flags: PacketFlags§hops: u8§transport_id: Option<[u8; 16]>§destination_hash: [u8; 16]§context: u8§data: Vec<u8>§raw: Vec<u8>§packet_hash: [u8; 32]Implementations§
Source§impl RawPacket
impl RawPacket
Sourcepub fn pack(
flags: PacketFlags,
hops: u8,
destination_hash: &[u8; 16],
transport_id: Option<&[u8; 16]>,
context: u8,
data: &[u8],
) -> Result<Self, PacketError>
pub fn pack( flags: PacketFlags, hops: u8, destination_hash: &[u8; 16], transport_id: Option<&[u8; 16]>, context: u8, data: &[u8], ) -> Result<Self, PacketError>
Pack fields into raw bytes.
Sourcepub fn unpack(raw: &[u8]) -> Result<Self, PacketError>
pub fn unpack(raw: &[u8]) -> Result<Self, PacketError>
Unpack raw bytes into fields.
Sourcepub fn get_hashable_part(&self) -> Vec<u8> ⓘ
pub fn get_hashable_part(&self) -> Vec<u8> ⓘ
Get the hashable part of the packet.
From Python Packet.py:354-361:
- Take raw[0] & 0x0F (mask out upper 4 bits of flags)
- For HEADER_1: append raw[2:]
- For HEADER_2: skip transport_id: append raw[18:]
Sourcepub fn get_truncated_hash(&self) -> [u8; 16]
pub fn get_truncated_hash(&self) -> [u8; 16]
Truncated hash (first 16 bytes) of the hashable part.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RawPacket
impl RefUnwindSafe for RawPacket
impl Send for RawPacket
impl Sync for RawPacket
impl Unpin for RawPacket
impl UnwindSafe for RawPacket
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