pub struct GradientRoutingTable { /* private fields */ }Expand description
Gradient routing table for directed message delivery. Learns routes from incoming messages and uses them for replies.
Implementations§
Source§impl GradientRoutingTable
impl GradientRoutingTable
Sourcepub fn with_config(config: GradientRoutingConfig) -> Self
pub fn with_config(config: GradientRoutingConfig) -> Self
Creates a new gradient routing table with custom configuration.
Sourcepub fn learn_route(
&mut self,
destination: &str,
next_hop: &str,
hop_count: u8,
quality: f32,
sequence_number: u32,
)
pub fn learn_route( &mut self, destination: &str, next_hop: &str, hop_count: u8, quality: f32, sequence_number: u32, )
Records a route learned from an incoming message (DSDV-style).
Prefers higher sequence_number (fresher from destination) to avoid loops.
Pass 0 for sequence when the message does not carry a destination sequence.
Sourcepub fn get_route(&self, destination: &str) -> Option<&RouteEntry>
pub fn get_route(&self, destination: &str) -> Option<&RouteEntry>
Gets the best route to a destination, if known.
Sourcepub fn get_routes(&self, destination: &str) -> Vec<&RouteEntry>
pub fn get_routes(&self, destination: &str) -> Vec<&RouteEntry>
Gets all valid routes to a destination.
Sourcepub fn has_route(&self, destination: &str) -> bool
pub fn has_route(&self, destination: &str) -> bool
Checks if we have a known route to a destination.
Sourcepub fn remove_neighbor(&mut self, neighbor: &str)
pub fn remove_neighbor(&mut self, neighbor: &str)
Removes a neighbor from the routing table (e.g., on disconnect).
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Cleans up expired routes.
Sourcepub fn destination_count(&self) -> usize
pub fn destination_count(&self) -> usize
Returns the number of known destinations.
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Returns the total number of routes.
Trait Implementations§
Source§impl Debug for GradientRoutingTable
impl Debug for GradientRoutingTable
Auto Trait Implementations§
impl Freeze for GradientRoutingTable
impl RefUnwindSafe for GradientRoutingTable
impl Send for GradientRoutingTable
impl Sync for GradientRoutingTable
impl Unpin for GradientRoutingTable
impl UnsafeUnpin for GradientRoutingTable
impl UnwindSafe for GradientRoutingTable
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