pub struct PacketKeyRing { /* private fields */ }Expand description
Bounded packet key lifecycle metadata.
Implementations§
Source§impl PacketKeyRing
impl PacketKeyRing
Sourcepub fn new(config: PacketKeyRingConfig) -> Self
pub fn new(config: PacketKeyRingConfig) -> Self
Creates an empty key ring.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Creates an empty key ring with default limits.
Sourcepub const fn config(&self) -> PacketKeyRingConfig
pub const fn config(&self) -> PacketKeyRingConfig
Returns configuration.
Sourcepub const fn stats(&self) -> PacketKeyRingStats
pub const fn stats(&self) -> PacketKeyRingStats
Returns statistics.
Sourcepub fn get(&self, key_id: u32) -> Option<PacketKeyDescriptor>
pub fn get(&self, key_id: u32) -> Option<PacketKeyDescriptor>
Returns one key descriptor.
Sourcepub fn iter(&self) -> impl Iterator<Item = &PacketKeyDescriptor>
pub fn iter(&self) -> impl Iterator<Item = &PacketKeyDescriptor>
Iterates key descriptors in key-id order.
Sourcepub fn insert(
&mut self,
descriptor: PacketKeyDescriptor,
) -> Result<(), PacketKeyRingError>
pub fn insert( &mut self, descriptor: PacketKeyDescriptor, ) -> Result<(), PacketKeyRingError>
Inserts a descriptor if capacity and uniqueness allow it.
Sourcepub fn insert_active(
&mut self,
key_id: u32,
now: Tick,
send_priority: u32,
) -> Result<(), PacketKeyRingError>
pub fn insert_active( &mut self, key_id: u32, now: Tick, send_priority: u32, ) -> Result<(), PacketKeyRingError>
Inserts active key metadata.
Sourcepub fn activate(
&mut self,
key_id: u32,
activated_at: Tick,
) -> Result<(), PacketKeyRingError>
pub fn activate( &mut self, key_id: u32, activated_at: Tick, ) -> Result<(), PacketKeyRingError>
Marks a key active and send-eligible from activated_at.
Sourcepub fn retire(
&mut self,
key_id: u32,
retires_at: Tick,
) -> Result<(), PacketKeyRingError>
pub fn retire( &mut self, key_id: u32, retires_at: Tick, ) -> Result<(), PacketKeyRingError>
Marks a key receive-only for retirement.
Sourcepub fn set_expiry(
&mut self,
key_id: u32,
expires_at: Option<Tick>,
) -> Result<(), PacketKeyRingError>
pub fn set_expiry( &mut self, key_id: u32, expires_at: Option<Tick>, ) -> Result<(), PacketKeyRingError>
Updates the expiration tick for one key.
Sourcepub fn remove_expired(&mut self, now: Tick) -> usize
pub fn remove_expired(&mut self, now: Tick) -> usize
Removes expired descriptors and returns the removed count.
Sourcepub fn select_send_key(
&self,
now: Tick,
) -> Result<PacketKeyDescriptor, PacketKeyRingError>
pub fn select_send_key( &self, now: Tick, ) -> Result<PacketKeyDescriptor, PacketKeyRingError>
Selects the best active key for sending at now.
Sourcepub fn accept_key(
&self,
key_id: u32,
now: Tick,
) -> Result<PacketKeyDescriptor, PacketKeyRingError>
pub fn accept_key( &self, key_id: u32, now: Tick, ) -> Result<PacketKeyDescriptor, PacketKeyRingError>
Checks that key_id is accepted for receiving at now.
Trait Implementations§
Source§impl Clone for PacketKeyRing
impl Clone for PacketKeyRing
Source§fn clone(&self) -> PacketKeyRing
fn clone(&self) -> PacketKeyRing
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PacketKeyRing
impl Debug for PacketKeyRing
Auto Trait Implementations§
impl Freeze for PacketKeyRing
impl RefUnwindSafe for PacketKeyRing
impl Send for PacketKeyRing
impl Sync for PacketKeyRing
impl Unpin for PacketKeyRing
impl UnsafeUnpin for PacketKeyRing
impl UnwindSafe for PacketKeyRing
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