Trait SocketService

Source
pub trait SocketService: 'static {
    type RequestDeserializer: Deserializer<Message: Message> + 'static;
    type ResponseSerializer: Serializer<Message: Message> + 'static;
    type ConnectionService: ConnectionService<Request = <Self::RequestDeserializer as Deserializer>::Message, Response = <Self::ResponseSerializer as Serializer>::Message>;

    // Required methods
    fn deserializer(&self) -> Self::RequestDeserializer;
    fn serializer(&self) -> Self::ResponseSerializer;
    fn new_connection_service(
        &self,
        address: SocketAddr,
    ) -> Self::ConnectionService;
}
Expand description

SocketService receives connections and produces ConnectionServices.

The SocketService is notified when a new connection is established. It is given the address of the remote peer and it returns a ConnectionService for that connection. You can think of this as the “connection factory” for your server. It is the “top” of your service stack.

Required Associated Types§

Source

type RequestDeserializer: Deserializer<Message: Message> + 'static

The type of deserializer for incoming messages.

Source

type ResponseSerializer: Serializer<Message: Message> + 'static

The type of serializer for outgoing messages.

Source

type ConnectionService: ConnectionService<Request = <Self::RequestDeserializer as Deserializer>::Message, Response = <Self::ResponseSerializer as Serializer>::Message>

The type of connection service that will be created for each connection.

Required Methods§

Source

fn deserializer(&self) -> Self::RequestDeserializer

Create a new deserializer for incoming messages.

Source

fn serializer(&self) -> Self::ResponseSerializer

Create a new serializer for outgoing messages.

Source

fn new_connection_service(&self, address: SocketAddr) -> Self::ConnectionService

Create a new ConnectionService for a new connection.

Implementors§