p2panda_net

Trait ProtocolHandler

Source
pub trait ProtocolHandler:
    Send
    + Sync
    + IntoArcAny
    + Debug
    + 'static {
    // Required method
    fn accept(self: Arc<Self>, conn: Connecting) -> BoxedFuture<Result<()>>;

    // Provided method
    fn shutdown(self: Arc<Self>) -> BoxedFuture<()> { ... }
}
Expand description

Interface to accept incoming connections for custom protocol implementations.

A node can accept connections for custom protocols. By default, the node only accepts connections for the core protocols (gossip and optionally sync or blobs).

Required Methods§

Source

fn accept(self: Arc<Self>, conn: Connecting) -> BoxedFuture<Result<()>>

Handle an incoming connection.

This runs on a freshly spawned tokio task so this can be long-running.

Provided Methods§

Source

fn shutdown(self: Arc<Self>) -> BoxedFuture<()>

Called when the node shuts down.

Implementations on Foreign Types§

Source§

impl ProtocolHandler for Gossip

Source§

fn accept(self: Arc<Self>, conn: Connecting) -> BoxedFuture<Result<()>>

Implementors§