Struct overnet_core::Router
source · pub struct Router { /* private fields */ }
Expand description
Router maintains global state for one node_id.
LinkData
is a token identifying a link for layers above Router.
Time
is a representation of time for the Router, to assist injecting different platforms
schemes.
Implementations§
source§impl Router
impl Router
sourcepub fn new(router_interval: Option<Duration>) -> Result<Arc<Self>, Error>
pub fn new(router_interval: Option<Duration>) -> Result<Arc<Self>, Error>
Create a new router. If router_interval
is given, this router will
behave like an interior node and tell its neighbors about each other.
sourcepub fn with_node_id(
node_id: NodeId,
router_interval: Option<Duration>,
) -> Result<Arc<Self>, Error>
pub fn with_node_id( node_id: NodeId, router_interval: Option<Duration>, ) -> Result<Arc<Self>, Error>
Make a router with a specific node ID.
sourcepub fn circuit_node(&self) -> &Node
pub fn circuit_node(&self) -> &Node
Get the circuit protocol node for this router. This will let us create new connections to other nodes.
sourcepub fn client_routing(&self) -> AscenddClientRouting
pub fn client_routing(&self) -> AscenddClientRouting
Accessor for whether to route ascendd clients to each other
sourcepub fn set_client_routing(&self, client_routing: AscenddClientRouting)
pub fn set_client_routing(&self, client_routing: AscenddClientRouting)
Setter for whether to route ascendd clients to each other
sourcepub async fn connect_to_service(
self: &Arc<Self>,
node_id: NodeId,
service_name: &str,
chan: Channel,
) -> Result<(), Error>
pub async fn connect_to_service( self: &Arc<Self>, node_id: NodeId, service_name: &str, chan: Channel, ) -> Result<(), Error>
Create a new stream to advertised service service
on remote node id node
.
sourcepub async fn register_service(
&self,
service_name: String,
provider: impl Fn(Channel) -> Result<(), Error> + Send + 'static,
) -> Result<(), Error>
pub async fn register_service( &self, service_name: String, provider: impl Fn(Channel) -> Result<(), Error> + Send + 'static, ) -> Result<(), Error>
Register a service. The callback should connect the given channel to the service in question.
sourcepub async fn new_list_peers_context(&self) -> ListPeersContext
pub async fn new_list_peers_context(&self) -> ListPeersContext
Create a new list_peers context