pub struct Packet {
pub packet_type: PacketType,
pub source: Option<PeerId>,
pub destination: Option<PeerId>,
pub sequence: u64,
pub timestamp: u64,
pub payload: Bytes,
pub signature: Option<Vec<u8>>,
pub routing_hints: Option<Vec<PeerId>>,
}Expand description
A packet in the shadow network
Fields§
§packet_type: PacketTypeType of packet
source: Option<PeerId>Source peer ID (may be obfuscated)
destination: Option<PeerId>Destination peer ID (may be obfuscated)
sequence: u64Sequence number (for ordering and deduplication)
timestamp: u64Timestamp (Unix epoch milliseconds)
payload: BytesPayload data (encrypted and/or steganographically encoded)
signature: Option<Vec<u8>>Signature (Ed25519, 64 bytes)
routing_hints: Option<Vec<PeerId>>Routing hints for multi-hop paths
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn new(
packet_type: PacketType,
source: Option<PeerId>,
destination: Option<PeerId>,
payload: Bytes,
) -> Self
pub fn new( packet_type: PacketType, source: Option<PeerId>, destination: Option<PeerId>, payload: Bytes, ) -> Self
Create a new packet
Sourcepub fn from_bytes(data: &[u8]) -> Result<Self>
pub fn from_bytes(data: &[u8]) -> Result<Self>
Deserialize packet from bytes
Sourcepub fn with_sequence(self, sequence: u64) -> Self
pub fn with_sequence(self, sequence: u64) -> Self
Set sequence number
Sourcepub fn with_routing_hints(self, hints: Vec<PeerId>) -> Self
pub fn with_routing_hints(self, hints: Vec<PeerId>) -> Self
Set routing hints
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Packet
impl<'de> Deserialize<'de> for Packet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl !Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnsafeUnpin for Packet
impl UnwindSafe for Packet
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