pub struct Packet { /* private fields */ }Expand description
Represents a packet to be sent out.
Note that each piece of the packet is associated with a key. The keys don’t have to be unique – more than one piece can be associated with a single key. For example, if a node is meant to both receive a message and transport the packet further, those two might be encrypted with the same key.
Implementations§
Source§impl Packet
impl Packet
Sourcepub fn signed(skey: SecretKey) -> Packet
pub fn signed(skey: SecretKey) -> Packet
Creates a packet whose chunks will be signed by the given key.
Sourcepub fn reply_to(&mut self, msg: &Message) -> Result<()>
pub fn reply_to(&mut self, msg: &Message) -> Result<()>
If the message has a reply block, adds it to this packet’s instructions.
If the message doesn’t have a reply block, the packet is unchanged.
Note that the reply block is pre-encrypted and, if applicable, pre-signed by the original sender. The contents will not be signed, even if this packet is a signed one.
Sourcepub fn add_message(&mut self, data: &[u8], node_pkey: &PublicKey)
pub fn add_message(&mut self, data: &[u8], node_pkey: &PublicKey)
Adds a message to the packet, for the node with the right skey to read.
Sourcepub fn add_hop(&mut self, path: String, node_pkey: &PublicKey)
pub fn add_hop(&mut self, path: String, node_pkey: &PublicKey)
Adds a hop to the packet, so that when it reaches the node with the right skey, it’ll get forwarded along the given path.
Sourcepub fn add_reply_path(&mut self) -> Option<ReplyPathHandle<'_>>
pub fn add_reply_path(&mut self) -> Option<ReplyPathHandle<'_>>
Starts creating a reply path.