RouterTable

Trait RouterTable 

Source
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§

Source

fn closest_for(&self, key: NodeId) -> Option<Remote>

Find the closest node for the given key

Source

fn next(&self, dest: NodeId) -> Option<Remote>

Find the next node for the given destination node

Source

fn path_to_node(&self, dest: NodeId) -> RouteAction<Remote>

Determine the next action for the given destination node

Source

fn path_to_key(&self, key: NodeId) -> RouteAction<Remote>

Determine the next action for the given key

Source

fn path_to_service(&self, service_id: u8) -> RouteAction<Remote>

Determine the next action for the given service

Source

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§

Source

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

Implementors§

Source§

impl<Conn: Debug + Hash + Eq + Clone + Copy, Remote: Debug + Hash + Eq + Clone + Copy> RouterTable<Remote> for ShadowRouter<Conn, Remote>