pub struct CoordCache { /* private fields */ }Expand description
Coordinate cache for routing decisions.
Maps node addresses to their tree coordinates, enabling data packets to be routed without carrying coordinates in every packet. Populated by SessionSetup packets.
Implementations§
Source§impl CoordCache
impl CoordCache
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a cache with default parameters.
Sourcepub fn max_entries(&self) -> usize
pub fn max_entries(&self) -> usize
Get the maximum capacity.
Sourcepub fn default_ttl_ms(&self) -> u64
pub fn default_ttl_ms(&self) -> u64
Get the default TTL.
Sourcepub fn set_default_ttl_ms(&mut self, ttl_ms: u64)
pub fn set_default_ttl_ms(&mut self, ttl_ms: u64)
Set the default TTL.
Sourcepub fn insert(
&mut self,
addr: NodeAddr,
coords: TreeCoordinate,
current_time_ms: u64,
)
pub fn insert( &mut self, addr: NodeAddr, coords: TreeCoordinate, current_time_ms: u64, )
Insert or update a cache entry.
Sourcepub fn insert_with_path_mtu(
&mut self,
addr: NodeAddr,
coords: TreeCoordinate,
current_time_ms: u64,
path_mtu: u16,
)
pub fn insert_with_path_mtu( &mut self, addr: NodeAddr, coords: TreeCoordinate, current_time_ms: u64, path_mtu: u16, )
Insert or update a cache entry with path MTU information.
Used by discovery response handling to store the discovered path MTU alongside the target’s coordinates.
Sourcepub fn insert_with_ttl(
&mut self,
addr: NodeAddr,
coords: TreeCoordinate,
current_time_ms: u64,
ttl_ms: u64,
)
pub fn insert_with_ttl( &mut self, addr: NodeAddr, coords: TreeCoordinate, current_time_ms: u64, ttl_ms: u64, )
Insert with a custom TTL.
Sourcepub fn get(
&self,
addr: &NodeAddr,
current_time_ms: u64,
) -> Option<&TreeCoordinate>
pub fn get( &self, addr: &NodeAddr, current_time_ms: u64, ) -> Option<&TreeCoordinate>
Look up coordinates for an address (without touching).
Sourcepub fn get_and_touch(
&mut self,
addr: &NodeAddr,
current_time_ms: u64,
) -> Option<&TreeCoordinate>
pub fn get_and_touch( &mut self, addr: &NodeAddr, current_time_ms: u64, ) -> Option<&TreeCoordinate>
Look up coordinates and refresh (update last_used and extend TTL).
Sourcepub fn get_entry(&self, addr: &NodeAddr) -> Option<&CacheEntry>
pub fn get_entry(&self, addr: &NodeAddr) -> Option<&CacheEntry>
Get the full cache entry.
Sourcepub fn remove(&mut self, addr: &NodeAddr) -> Option<CacheEntry>
pub fn remove(&mut self, addr: &NodeAddr) -> Option<CacheEntry>
Remove an entry.
Sourcepub fn contains(&self, addr: &NodeAddr, current_time_ms: u64) -> bool
pub fn contains(&self, addr: &NodeAddr, current_time_ms: u64) -> bool
Check if an address is cached (and not expired).
Sourcepub fn iter(
&self,
current_time_ms: u64,
) -> impl Iterator<Item = (&NodeAddr, &CacheEntry)>
pub fn iter( &self, current_time_ms: u64, ) -> impl Iterator<Item = (&NodeAddr, &CacheEntry)>
Iterate over non-expired entries.
Sourcepub fn purge_expired(&mut self, current_time_ms: u64) -> usize
pub fn purge_expired(&mut self, current_time_ms: u64) -> usize
Remove all expired entries.
Sourcepub fn stats(&self, current_time_ms: u64) -> CacheStats
pub fn stats(&self, current_time_ms: u64) -> CacheStats
Get cache statistics.
Trait Implementations§
Source§impl Clone for CoordCache
impl Clone for CoordCache
Source§fn clone(&self) -> CoordCache
fn clone(&self) -> CoordCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CoordCache
impl Debug for CoordCache
Auto Trait Implementations§
impl Freeze for CoordCache
impl RefUnwindSafe for CoordCache
impl Send for CoordCache
impl Sync for CoordCache
impl Unpin for CoordCache
impl UnsafeUnpin for CoordCache
impl UnwindSafe for CoordCache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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