pub struct PacketPool { /* private fields */ }Expand description
Pool of packet builders for amortized allocation.
Uses counter-based nonces for zero-allocation packet construction. All builders in the pool share a single TX counter to prevent nonce reuse.
Implementations§
Source§impl PacketPool
impl PacketPool
Sourcepub fn with_origin(
size: usize,
key: &[u8; 32],
session_id: u64,
origin_hash: u64,
) -> Self
pub fn with_origin( size: usize, key: &[u8; 32], session_id: u64, origin_hash: u64, ) -> Self
Create a new packet pool with origin identity
Sourcepub fn set_key(&mut self, key: &[u8; 32], session_id: u64)
pub fn set_key(&mut self, key: &[u8; 32], session_id: u64)
Update the encryption key and session ID.
Drains all pooled builders so that no stale builder can encrypt
with the old key while sharing a counter that restarted at zero
(which would cause nonce reuse and break ChaCha20-Poly1305).
Builders are lazily re-created with the new key on the next get().
Sourcepub fn session_id(&self) -> u64
pub fn session_id(&self) -> u64
Get the session ID
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PacketPool
impl RefUnwindSafe for PacketPool
impl Send for PacketPool
impl Sync for PacketPool
impl Unpin for PacketPool
impl UnsafeUnpin for PacketPool
impl UnwindSafe for PacketPool
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