pub struct Router { /* private fields */ }Expand description
Production-ready multi-path router with advanced load balancing and dark addressing
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(message_tx: Sender<Vec<u8>>) -> Self
pub fn new(message_tx: Sender<Vec<u8>>) -> Self
Creates a new router instance with default configuration
Sourcepub fn new_with_config(
message_tx: Sender<Vec<u8>>,
scoring_config: PeerScoringConfig,
optimization_config: RouteOptimizationConfig,
dark_addressing_config: DarkAddressingConfig,
max_message_size: usize,
) -> Self
pub fn new_with_config( message_tx: Sender<Vec<u8>>, scoring_config: PeerScoringConfig, optimization_config: RouteOptimizationConfig, dark_addressing_config: DarkAddressingConfig, max_message_size: usize, ) -> Self
Creates a new production-ready router instance with custom configuration
Sourcepub fn set_shadow_resolver(
&mut self,
resolver: Box<dyn ShadowAddressResolver + Send + Sync>,
)
pub fn set_shadow_resolver( &mut self, resolver: Box<dyn ShadowAddressResolver + Send + Sync>, )
Set the shadow address resolver
Sourcepub fn add_peer_connection(&mut self, from: LibP2PPeerId, to: LibP2PPeerId)
pub fn add_peer_connection(&mut self, from: LibP2PPeerId, to: LibP2PPeerId)
Adds a peer connection to the routing table
Sourcepub fn remove_peer_connection(&mut self, from: LibP2PPeerId, to: LibP2PPeerId)
pub fn remove_peer_connection(&mut self, from: LibP2PPeerId, to: LibP2PPeerId)
Removes a peer connection from the routing table
Sourcepub async fn add_discovered_peer(
&self,
peer_id: LibP2PPeerId,
peer: DiscoveredPeer,
)
pub async fn add_discovered_peer( &self, peer_id: LibP2PPeerId, peer: DiscoveredPeer, )
Adds a discovered peer with full metrics
Sourcepub async fn remove_discovered_peer(&self, peer_id: LibP2PPeerId)
pub async fn remove_discovered_peer(&self, peer_id: LibP2PPeerId)
Removes a discovered peer
Sourcepub async fn update_path_metrics(&self, peer_id: LibP2PPeerId, path: RoutePath)
pub async fn update_path_metrics(&self, peer_id: LibP2PPeerId, path: RoutePath)
Updates path metrics for a peer
Sourcepub async fn find_paths(
&self,
destination: LibP2PPeerId,
criteria: &RouteSelectionCriteria,
) -> Result<Vec<RoutePath>, RoutingError>
pub async fn find_paths( &self, destination: LibP2PPeerId, criteria: &RouteSelectionCriteria, ) -> Result<Vec<RoutePath>, RoutingError>
Finds multiple disjoint paths to a destination
Sourcepub async fn route_message(
&self,
destination: impl Into<Destination>,
message: Vec<u8>,
) -> Result<(), RoutingError>
pub async fn route_message( &self, destination: impl Into<Destination>, message: Vec<u8>, ) -> Result<(), RoutingError>
Routes a message through multiple paths using either PeerId or ShadowAddress
Auto Trait Implementations§
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Freeze for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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> ⓘ
Converts
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> ⓘ
Converts
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