Skip to main content

RoomProvider

Trait RoomProvider 

Source
pub trait RoomProvider<ClientToServerMessage, ServerToClientMessage> {
    type ServerToClientStream: Stream<Item = ServerToClientMessage> + Unpin + Send + 'static;
    type FinishFuture: Future<Output = ()> + Unpin + Send + 'static;

    // Required methods
    fn add(
        &mut self,
        client_to_server_stream: impl Stream<Item = ClientToServerMessage> + Unpin + Send + 'static,
    ) -> Self::ServerToClientStream;
    fn get_finish_signal(&mut self) -> Self::FinishFuture;
}
Expand description

Abstract of a duel.

Implementing this trait means it can accept a stream of ClientToServerMessage and return a stream of ServerToClientMessage.

Usually ClientToServerMessage is a derived type of ctos::Message, and ServerToClientMessage is a derived type of stoc::Message.

Required Associated Types§

Source

type ServerToClientStream: Stream<Item = ServerToClientMessage> + Unpin + Send + 'static

The stream of messages sent back to the client.

Source

type FinishFuture: Future<Output = ()> + Unpin + Send + 'static

A future that resolves when the room finishes.

Required Methods§

Source

fn add( &mut self, client_to_server_stream: impl Stream<Item = ClientToServerMessage> + Unpin + Send + 'static, ) -> Self::ServerToClientStream

Add a client-to-server stream and return the corresponding server-to-client stream.

Source

fn get_finish_signal(&mut self) -> Self::FinishFuture

Get a future that resolves when the room finishes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§