pub struct DnsCacheRing<const N: usize = DEFAULT_DNS_CACHE_CAPACITY> { /* private fields */ }Expand description
Zero-allocation ring buffer storing NQuin records.
Implementations§
Source§impl<const N: usize> DnsCacheRing<N>
impl<const N: usize> DnsCacheRing<N>
Sourcepub fn insert(&mut self, quin: NQuin, current_clock: u32)
pub fn insert(&mut self, quin: NQuin, current_clock: u32)
Insert a quin into the ring buffer, evicting the oldest entry on wrap.
Sourcepub fn lookup(&self, subject_hash: u64, opcode: u8) -> Option<NQuin>
pub fn lookup(&self, subject_hash: u64, opcode: u8) -> Option<NQuin>
Find the most recent record matching subject_hash and opcode.
Searches backwards from most recently inserted to oldest. Zero-allocation.
Sourcepub fn lookup_valid(
&self,
subject_hash: u64,
opcode: u8,
current_clock: u32,
) -> Option<NQuin>
pub fn lookup_valid( &self, subject_hash: u64, opcode: u8, current_clock: u32, ) -> Option<NQuin>
Find the most recent record matching subject_hash and opcode that has NOT expired.
Verifies current_clock < inserted_clock + ttl. Zero-allocation.
Sourcepub fn lookup_all(&self, subject_hash: u64, out: &mut [NQuin]) -> usize
pub fn lookup_all(&self, subject_hash: u64, out: &mut [NQuin]) -> usize
Collect all records matching subject_hash into a caller-supplied buffer.
Returns the number of items written into out. Zero-allocation.
Sourcepub fn prune_expired(&mut self, current_clock: u32) -> usize
pub fn prune_expired(&mut self, current_clock: u32) -> usize
Prune all expired records from the ring buffer based on current_clock.
Reclaims slots and compacts active unexpired entries in place. Returns the count of pruned records. Zero heap allocation.
Sourcepub fn prune_older_than(&mut self, cutoff_clock: u32) -> usize
pub fn prune_older_than(&mut self, cutoff_clock: u32) -> usize
Prune records inserted strictly before cutoff_clock.
Returns the count of pruned records. Zero heap allocation.
Sourcepub fn archive_expired_into(
&mut self,
current_clock: u32,
archive_sink: &mut [NQuin],
) -> usize
pub fn archive_expired_into( &mut self, current_clock: u32, archive_sink: &mut [NQuin], ) -> usize
Archive all expired records into archive_sink and remove them from the ring buffer.
Returns the count of archived records written into archive_sink. Zero heap allocation.
Sourcepub fn archive_older_than(
&mut self,
cutoff_clock: u32,
archive_sink: &mut [NQuin],
) -> usize
pub fn archive_older_than( &mut self, cutoff_clock: u32, archive_sink: &mut [NQuin], ) -> usize
Archive records inserted before cutoff_clock into archive_sink and remove them.
Returns the count of archived records written into archive_sink. Zero heap allocation.
Trait Implementations§
Source§impl<const N: usize> Clone for DnsCacheRing<N>
impl<const N: usize> Clone for DnsCacheRing<N>
Source§impl<const N: usize> Debug for DnsCacheRing<N>
impl<const N: usize> Debug for DnsCacheRing<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for DnsCacheRing<N>
impl<const N: usize> RefUnwindSafe for DnsCacheRing<N>
impl<const N: usize> Send for DnsCacheRing<N>
impl<const N: usize> Sync for DnsCacheRing<N>
impl<const N: usize> Unpin for DnsCacheRing<N>
impl<const N: usize> UnsafeUnpin for DnsCacheRing<N>
impl<const N: usize> UnwindSafe for DnsCacheRing<N>
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more