pub trait Transport:
'static
+ Send
+ Sync
+ Debug {
// Required methods
fn register_space_handler(
&self,
space: SpaceId,
handler: DynTxSpaceHandler,
) -> Option<Url>;
fn register_module_handler(
&self,
space: SpaceId,
module: String,
handler: DynTxModuleHandler,
);
fn disconnect(&self, peer: Url, reason: Option<String>) -> BoxFut<'_, ()>;
fn send_space_notify(
&self,
peer: Url,
space: SpaceId,
data: Bytes,
) -> BoxFut<'_, K2Result<()>>;
fn send_module(
&self,
peer: Url,
space: SpaceId,
module: String,
data: Bytes,
) -> BoxFut<'_, K2Result<()>>;
fn get_connected_peers(&self) -> BoxFut<'_, K2Result<Vec<Url>>>;
fn unregister_space(&self, space: SpaceId) -> BoxFut<'_, ()>;
fn dump_network_stats(&self) -> BoxFut<'_, K2Result<TransportStats>>;
}Expand description
A high-level wrapper around a low-level DynTxImp transport implementation.
Required Methods§
Sourcefn register_space_handler(
&self,
space: SpaceId,
handler: DynTxSpaceHandler,
) -> Option<Url>
fn register_space_handler( &self, space: SpaceId, handler: DynTxSpaceHandler, ) -> Option<Url>
Register a space handler for receiving incoming notifications.
Panics if you attempt to register a duplicate handler for a space.
Returns the current url if any.
Sourcefn register_module_handler(
&self,
space: SpaceId,
module: String,
handler: DynTxModuleHandler,
)
fn register_module_handler( &self, space: SpaceId, module: String, handler: DynTxModuleHandler, )
Register a module handler for receiving incoming module messages.
Panics if you attempt to register a duplicate handler for the same (space, module).
Sourcefn disconnect(&self, peer: Url, reason: Option<String>) -> BoxFut<'_, ()>
fn disconnect(&self, peer: Url, reason: Option<String>) -> BoxFut<'_, ()>
Make a best effort to notify a peer that we are disconnecting and why. After a short time out, the connection will be closed even if the disconnect reason message is still pending.
Sourcefn send_space_notify(
&self,
peer: Url,
space: SpaceId,
data: Bytes,
) -> BoxFut<'_, K2Result<()>>
fn send_space_notify( &self, peer: Url, space: SpaceId, data: Bytes, ) -> BoxFut<'_, K2Result<()>>
Notify a remote peer within a space. This is a fire-and-forget
type message. The future this call returns will indicate any errors
that occur up to the point where the message is handed off to
the transport backend. After that, the future will return Ok(())
but the remote peer may or may not actually receive the message.
Sourcefn send_module(
&self,
peer: Url,
space: SpaceId,
module: String,
data: Bytes,
) -> BoxFut<'_, K2Result<()>>
fn send_module( &self, peer: Url, space: SpaceId, module: String, data: Bytes, ) -> BoxFut<'_, K2Result<()>>
Notify a remote peer module within a space. This is a fire-and-forget
type message. The future this call returns will indicate any errors
that occur up to the point where the message is handed off to
the transport backend. After that, the future will return Ok(())
but the remote peer may or may not actually receive the message.
Sourcefn get_connected_peers(&self) -> BoxFut<'_, K2Result<Vec<Url>>>
fn get_connected_peers(&self) -> BoxFut<'_, K2Result<Vec<Url>>>
Get the list of connected peers.
Sourcefn unregister_space(&self, space: SpaceId) -> BoxFut<'_, ()>
fn unregister_space(&self, space: SpaceId) -> BoxFut<'_, ()>
Unregister a space handler and all module handlers for that space.
Sourcefn dump_network_stats(&self) -> BoxFut<'_, K2Result<TransportStats>>
fn dump_network_stats(&self) -> BoxFut<'_, K2Result<TransportStats>>
Dump network stats.