ServerConn

Trait ServerConn 

Source
pub trait ServerConn {
    type ClientMsg: Serialize + for<'de> Deserialize<'de> + Send + 'static;
    type ServerMsg: Serialize + for<'de> Deserialize<'de> + Send + 'static;

    // Required methods
    fn handle_message(&mut self, message: Self::ClientMsg) -> Self::ServerMsg;
    fn new() -> Self;
}
Expand description

Trait that simplifies the creation of the server side of a socket protocol.

Required Associated Types§

Source

type ClientMsg: Serialize + for<'de> Deserialize<'de> + Send + 'static

Source

type ServerMsg: Serialize + for<'de> Deserialize<'de> + Send + 'static

Required Methods§

Source

fn handle_message(&mut self, message: Self::ClientMsg) -> Self::ServerMsg

§Handle Message

This function runs every time the server-conn receives a client message. You need to decide what message tp respond with.

Source

fn new() -> Self

Opens a new server connection.

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§