Trait Protocol

Source
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§

Source

type ResponseBody: Body + Send + 'static

The body type for the protocol.

Source

type Error: Into<Box<dyn Error + Send + Sync>>

The error when a connection has a problem.

Source

type Connection: Connection + Future<Output = Result<(), Self::Error>> + 'static

The connection future, used to drive a connection IO to completion.

Required Methods§

Source

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.

Implementors§

Source§

impl<S, IO, BIn, BOut> Protocol<S, IO, BIn> for hyperdriver::server::conn::http1::Builder
where S: Service<Request<BIn>, Response = Response<BOut>> + Clone + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, BIn: From<Incoming> + Send + 'static, BOut: Body + Send + 'static, BOut::Error: Into<Box<dyn Error + Send + Sync>>, BOut::Data: Send, IO: AsyncRead + AsyncWrite + Send + Unpin + 'static,

Source§

impl<S, IO, BIn, BOut, E> Protocol<S, IO, BIn> for hyperdriver::server::conn::auto::Builder<E>
where S: Service<Request<BIn>, Response = Response<BOut>> + Clone + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, BIn: Body + From<Incoming> + 'static, BOut: Body + Send + 'static, BOut::Data: Send + 'static, BOut::Error: Into<Box<dyn Error + Send + Sync>>, IO: AsyncRead + AsyncWrite + Send + Unpin + 'static, E: Http2ServerConnExec<<TowerHyperService<IncomingRequestService<S, BIn, BOut>> as HttpService<Incoming>>::Future, BOut> + Clone + Send + Sync + 'static,

Source§

type ResponseBody = BOut

Source§

type Connection = Connecting<S, IO, BIn, BOut, E>

Source§

type Error = ConnectionError

Source§

impl<S, IO, BIn, BOut, E> Protocol<S, IO, BIn> for hyperdriver::server::conn::http2::Builder<E>
where S: Service<Request<BIn>, Response = Response<BOut>> + Clone + 'static, S::Future: 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, BIn: Body + From<Incoming> + Send + 'static, BOut: Body + Send + 'static, BOut::Error: Into<Box<dyn Error + Send + Sync>>, BOut::Data: Send + 'static, IO: AsyncRead + AsyncWrite + Unpin + 'static, E: Http2ServerConnExec<TowerHyperFuture<IncomingRequestService<S, BIn, BOut>, Request<Incoming>>, BOut> + Clone + Send + 'static,