pub struct DynamicSeenCache { /* private fields */ }Expand description
A duplicate cache whose size is chosen when it is built, rather than at compile time.
SeenCache fixes its capacity in the type, which suits a microcontroller that knows
its own limits. A gateway, or any caller reaching this through a language binding, does
not know the size until it runs, and a const generic cannot cross a foreign function
boundary at all. This is the same cache with its slots on the heap, so both share one
implementation and answer identically.
Requires the alloc feature.
§Examples
use pamoja_mesh::DynamicSeenCache;
// A busy relay remembers more packets than a leaf node needs to.
let mut seen = DynamicSeenCache::new(1024);
assert!(seen.record((0x42, 1)));
assert!(!seen.record((0x42, 1)));
assert_eq!(seen.capacity(), 1024);Implementations§
Trait Implementations§
Source§impl Clone for DynamicSeenCache
impl Clone for DynamicSeenCache
Source§fn clone(&self) -> DynamicSeenCache
fn clone(&self) -> DynamicSeenCache
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 moreAuto Trait Implementations§
impl Freeze for DynamicSeenCache
impl RefUnwindSafe for DynamicSeenCache
impl Send for DynamicSeenCache
impl Sync for DynamicSeenCache
impl Unpin for DynamicSeenCache
impl UnsafeUnpin for DynamicSeenCache
impl UnwindSafe for DynamicSeenCache
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