pub struct RawPacket {
pub flags: PacketFlags,
pub hops: u8,
pub transport_id: Option<[u8; 16]>,
pub destination_hash: [u8; 16],
pub context: u8,
pub raw: Vec<u8>,
pub packet_hash: [u8; 32],
pub rssi: Option<i16>,
pub snr: Option<f32>,
}Fields§
§flags: PacketFlags§hops: u8§transport_id: Option<[u8; 16]>§destination_hash: [u8; 16]§context: u8§raw: Vec<u8>§packet_hash: [u8; 32]§rssi: Option<i16>§snr: Option<f32>Implementations§
Source§impl RawPacket
impl RawPacket
Sourcepub const fn data_offset(header_type: u8) -> usize
pub const fn data_offset(header_type: u8) -> usize
Offset of the payload in the wire bytes of a packet with this header type.
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 pack_raw_with_hash(
flags: PacketFlags,
hops: u8,
destination_hash: &[u8; 16],
transport_id: Option<&[u8; 16]>,
context: u8,
data: &[u8],
) -> Result<(Vec<u8>, [u8; 32]), PacketError>
pub fn pack_raw_with_hash( flags: PacketFlags, hops: u8, destination_hash: &[u8; 16], transport_id: Option<&[u8; 16]>, context: u8, data: &[u8], ) -> Result<(Vec<u8>, [u8; 32]), PacketError>
Pack fields into raw bytes and packet hash without constructing a full RawPacket.
Sourcepub fn pack_with_max_mtu(
flags: PacketFlags,
hops: u8,
destination_hash: &[u8; 16],
transport_id: Option<&[u8; 16]>,
context: u8,
data: &[u8],
max_mtu: usize,
) -> Result<Self, PacketError>
pub fn pack_with_max_mtu( flags: PacketFlags, hops: u8, destination_hash: &[u8; 16], transport_id: Option<&[u8; 16]>, context: u8, data: &[u8], max_mtu: usize, ) -> Result<Self, PacketError>
Pack fields into raw bytes with a caller-provided MTU limit.
Sourcepub fn pack_raw_with_hash_with_max_mtu(
flags: PacketFlags,
hops: u8,
destination_hash: &[u8; 16],
transport_id: Option<&[u8; 16]>,
context: u8,
data: &[u8],
max_mtu: usize,
) -> Result<(Vec<u8>, [u8; 32]), PacketError>
pub fn pack_raw_with_hash_with_max_mtu( flags: PacketFlags, hops: u8, destination_hash: &[u8; 16], transport_id: Option<&[u8; 16]>, context: u8, data: &[u8], max_mtu: usize, ) -> Result<(Vec<u8>, [u8; 32]), PacketError>
Pack fields into raw bytes and packet hash with a caller-provided MTU limit.
Sourcepub fn pack_raw_with_max_mtu(
flags: PacketFlags,
hops: u8,
destination_hash: &[u8; 16],
transport_id: Option<&[u8; 16]>,
context: u8,
data: &[u8],
max_mtu: usize,
) -> Result<Vec<u8>, PacketError>
pub fn pack_raw_with_max_mtu( flags: PacketFlags, hops: u8, destination_hash: &[u8; 16], transport_id: Option<&[u8; 16]>, context: u8, data: &[u8], max_mtu: usize, ) -> Result<Vec<u8>, PacketError>
Pack only wire bytes when the caller does not need a packet hash. Validation and encoding match the hash-producing packing methods.
Sourcepub fn unpack(raw: &[u8]) -> Result<Self, PacketError>
pub fn unpack(raw: &[u8]) -> Result<Self, PacketError>
Unpack raw bytes into fields.
Sourcepub fn unpack_owned(raw: Vec<u8>) -> Result<Self, PacketError>
pub fn unpack_owned(raw: Vec<u8>) -> Result<Self, PacketError>
Unpack wire bytes the caller owns, keeping them as raw instead of
copying them.
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 cached packet hash.
Packet construction and unpacking compute packet_hash once; routing
paths use this prefix instead of hashing the raw packet again.