pub trait Protocol<S, IO, B> {
type ResponseBody: Body + Send + 'static;
type Error: Into<Box<dyn Error + Send + Sync>>;
type Connection: Connection + Future<Output = Result<(), Self::Error>> + 'static;
// Required method
fn serve_connection_with_upgrades(
&self,
stream: IO,
service: S,
) -> Self::Connection;
}
Available on crate feature
server
only.Expand description
A transport protocol for serving connections.
This is not meant to be the “accept” part of a server, but instead the connection management and serving part.
Required Associated Types§
Sourcetype ResponseBody: Body + Send + 'static
type ResponseBody: Body + Send + 'static
The body type for the protocol.
Sourcetype Connection: Connection + Future<Output = Result<(), Self::Error>> + 'static
type Connection: Connection + Future<Output = Result<(), Self::Error>> + 'static
The connection future, used to drive a connection IO to completion.
Required Methods§
Sourcefn serve_connection_with_upgrades(
&self,
stream: IO,
service: S,
) -> Self::Connection
fn serve_connection_with_upgrades( &self, stream: IO, service: S, ) -> Self::Connection
Serve a connection with possible upgrades.
Implementing this method does not guarantee that a protocol can be upgraded, just that we can serve the connection.