Trait KitsuneHandler

Source
pub trait KitsuneHandler:
    'static
    + Send
    + Sync
    + Debug {
    // Required method
    fn create_space(
        &self,
        space: SpaceId,
    ) -> BoxFut<'_, K2Result<DynSpaceHandler>>;

    // Provided methods
    fn new_listening_address(&self, this_url: Url) -> BoxFut<'static, ()> { ... }
    fn peer_disconnect(&self, peer: Url, reason: Option<String>) { ... }
    fn preflight_gather_outgoing(&self, peer_url: Url) -> K2Result<Bytes> { ... }
    fn preflight_validate_incoming(
        &self,
        peer_url: Url,
        data: Bytes,
    ) -> K2Result<()> { ... }
}
Expand description

Handler for events coming out of Kitsune2.

Required Methods§

Source

fn create_space(&self, space: SpaceId) -> BoxFut<'_, K2Result<DynSpaceHandler>>

Kitsune would like to construct a space. Provide a handler.

Provided Methods§

Source

fn new_listening_address(&self, this_url: Url) -> BoxFut<'static, ()>

A notification that a new listening address has been bound. Peers should now go to this new address to reach this node.

Source

fn peer_disconnect(&self, peer: Url, reason: Option<String>)

A peer has disconnected from us. If they did so gracefully the reason will be is_some().

Source

fn preflight_gather_outgoing(&self, peer_url: Url) -> K2Result<Bytes>

Gather preflight data to send to a new opening connection. Returning an Err result will close this connection.

The default implementation sends an empty preflight message.

Source

fn preflight_validate_incoming( &self, peer_url: Url, data: Bytes, ) -> K2Result<()>

Validate preflight data sent by a remote peer on a new connection. Returning an Err result will close this connection.

The default implementation ignores the preflight data, and considers it valid.

Implementors§