WSServerSocket

Trait WSServerSocket 

Source
pub trait WSServerSocket<ClientMsg: Serialize + for<'a> Deserialize<'a> + Send, ServerMsg: Serialize + Debug + for<'a> Deserialize<'a> + Send>:
    Sized
    + Sync
    + 'static {
    const TIMEOUT: f32 = 10f32;

    // Required methods
    fn new(
        socket: WSSocket<ClientMsg, ServerMsg>,
    ) -> impl Future<Output = Self> + Send;
    fn handle(&self, msg: ClientMsg) -> impl Future<Output = bool> + Send;
    fn span(&self) -> Option<&'static Span>;

    // Provided methods
    fn allow_user(state: LoginState) -> bool { ... }
    async fn handler(
        auth_session: AuthSession<DBBackend>,
        ws: WebSocketUpgrade,
    ) -> Response
       where Self: Send { ... }
}
Available on crate feature ssr only.

Provided Associated Constants§

Source

const TIMEOUT: f32 = 10f32

Required Methods§

Source

fn new( socket: WSSocket<ClientMsg, ServerMsg>, ) -> impl Future<Output = Self> + Send

Source

fn handle(&self, msg: ClientMsg) -> impl Future<Output = bool> + Send

Source

fn span(&self) -> Option<&'static Span>

Provided Methods§

Source

fn allow_user(state: LoginState) -> bool

Source

async fn handler( auth_session: AuthSession<DBBackend>, ws: WebSocketUpgrade, ) -> Response
where Self: 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§