Trait EventHandler

Source
pub trait EventHandler {
    type ClientUserData: Default + Send + Sync;

    // Required method
    fn on_request(
        &self,
        peer: &mut PeerContext<Self::ClientUserData>,
        request: Value,
    ) -> impl Future<Output = Result<Value>> + Send;

    // Provided methods
    fn on_connect(
        &self,
        _id: u64,
    ) -> impl Future<Output = Result<Self::ClientUserData>> + Send { ... }
    fn on_disconnect(&self, _id: u64) -> impl Future<Output = ()> + Send { ... }
}

Required Associated Types§

Required Methods§

Source

fn on_request( &self, peer: &mut PeerContext<Self::ClientUserData>, request: Value, ) -> impl Future<Output = Result<Value>> + Send

Provided Methods§

Source

fn on_connect( &self, _id: u64, ) -> impl Future<Output = Result<Self::ClientUserData>> + Send

Source

fn on_disconnect(&self, _id: u64) -> impl Future<Output = ()> + Send

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§