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§
Sourcetype RequestDeserializer: Deserializer<Message: Message> + 'static
type RequestDeserializer: Deserializer<Message: Message> + 'static
The type of deserializer for incoming messages.
Sourcetype ResponseSerializer: Serializer<Message: Message> + 'static
type ResponseSerializer: Serializer<Message: Message> + 'static
The type of serializer for outgoing messages.
Sourcetype ConnectionService: ConnectionService<Request = <Self::RequestDeserializer as Deserializer>::Message, Response = <Self::ResponseSerializer as Serializer>::Message>
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§
Sourcefn deserializer(&self) -> Self::RequestDeserializer
fn deserializer(&self) -> Self::RequestDeserializer
Create a new deserializer for incoming messages.
Sourcefn serializer(&self) -> Self::ResponseSerializer
fn serializer(&self) -> Self::ResponseSerializer
Create a new serializer for outgoing messages.
Sourcefn new_connection_service(&self, address: SocketAddr) -> Self::ConnectionService
fn new_connection_service(&self, address: SocketAddr) -> Self::ConnectionService
Create a new ConnectionService for a new connection.