pub trait RouterTable<Remote> {
// Required methods
fn closest_for(&self, key: NodeId) -> Option<Remote>;
fn next(&self, dest: NodeId) -> Option<Remote>;
fn path_to_node(&self, dest: NodeId) -> RouteAction<Remote>;
fn path_to_key(&self, key: NodeId) -> RouteAction<Remote>;
fn path_to_service(&self, service_id: u8) -> RouteAction<Remote>;
fn path_to_services(
&self,
service_id: u8,
seq: u16,
level: ServiceBroadcastLevel,
source: Option<NodeId>,
relay_from: Option<NodeId>,
) -> RouteAction<Remote>;
// Provided method
fn derive_action(
&self,
route: &RouteRule,
source: Option<NodeId>,
relay_from: Option<NodeId>,
) -> RouteAction<Remote> { ... }
}Required Methods§
Sourcefn closest_for(&self, key: NodeId) -> Option<Remote>
fn closest_for(&self, key: NodeId) -> Option<Remote>
Find the closest node for the given key
Sourcefn next(&self, dest: NodeId) -> Option<Remote>
fn next(&self, dest: NodeId) -> Option<Remote>
Find the next node for the given destination node
Sourcefn path_to_node(&self, dest: NodeId) -> RouteAction<Remote>
fn path_to_node(&self, dest: NodeId) -> RouteAction<Remote>
Determine the next action for the given destination node
Sourcefn path_to_key(&self, key: NodeId) -> RouteAction<Remote>
fn path_to_key(&self, key: NodeId) -> RouteAction<Remote>
Determine the next action for the given key
Sourcefn path_to_service(&self, service_id: u8) -> RouteAction<Remote>
fn path_to_service(&self, service_id: u8) -> RouteAction<Remote>
Determine the next action for the given service
Sourcefn path_to_services(
&self,
service_id: u8,
seq: u16,
level: ServiceBroadcastLevel,
source: Option<NodeId>,
relay_from: Option<NodeId>,
) -> RouteAction<Remote>
fn path_to_services( &self, service_id: u8, seq: u16, level: ServiceBroadcastLevel, source: Option<NodeId>, relay_from: Option<NodeId>, ) -> RouteAction<Remote>
Determine the next action if we need broadcast to all node running a service. If relay_from is set, it should not sending back for avoiding loop
Provided Methods§
Sourcefn derive_action(
&self,
route: &RouteRule,
source: Option<NodeId>,
relay_from: Option<NodeId>,
) -> RouteAction<Remote>
fn derive_action( &self, route: &RouteRule, source: Option<NodeId>, relay_from: Option<NodeId>, ) -> RouteAction<Remote>
Determine next action for incoming messages given the route rule and service id