Trait Transport

Source
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 dump_network_stats(&self) -> BoxFut<'_, K2Result<TransportStats>>;
}
Expand description

A high-level wrapper around a low-level DynTxImp transport implementation.

Required Methods§

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

fn dump_network_stats(&self) -> BoxFut<'_, K2Result<TransportStats>>

Dump network stats.

Implementors§