Skip to main content

build_connection

Function build_connection 

Source
pub fn build_connection<I, S, B>(
    io: I,
    service: S,
    http2_enabled: bool,
) -> UpgradeableConnection<'static, I, S, TokioExecutor>
where I: Read + Write + Unpin + Send + 'static, S: Service<Request<Incoming>, Response = Response<B>> + Send + 'static, S::Future: Send + 'static, S::Error: Into<Box<dyn Error + Send + Sync>>, B: Body + Send + 'static, B::Data: Send, B::Error: Into<Box<dyn Error + Send + Sync>>,
Expand description

Builds (but does not drive) a connection future for io, ready to be either .awaited directly or handed to a graceful-shutdown watcher.

Both protocol paths go through the hyper-util auto builder so they share one connection type that implements GracefulConnection: http1_only() for strict HTTP/1.1, or h2 (auto-detected, extended CONNECT enabled) otherwise. .into_owned() detaches the connection from the builder so it is 'static and can be spawned. See serve_connection for the simple await-and-log path.