Struct Connection
#[must_use = "futures do nothing unless polled"]
pub struct Connection<T, S>
where
S: HttpService<Incoming>, { /* private fields */ }
A Future representing an HTTP/1 connection, bound to a
Service, returned from
Builder::serve_connection.
To drive HTTP on this connection this future must be polled, typically with
.await. If it isn't polled, no progress will be made on this connection.
Implementations
impl<I, B, S> Connection<I, S>
where
S: HttpService<Incoming, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: Read + Write + Unpin,
B: Body + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
fn graceful_shutdown(self: Pin<&mut Self>)Start a graceful shutdown process for this connection.
This
Connectionshould continue to be polled until shutdown can finish.Note
This should only be called while the
Connectionfuture is still pending. If called afterConnection::pollhas resolved, this does nothing.fn into_parts(self) -> Parts<I, S>Return the inner IO object, and additional information.
If the IO object has been "rewound" the io will not contain those bytes rewound. This should only be called after
poll_without_shutdownsignals that the connection is "done". Otherwise, it may not have finished flushing all necessary HTTP bytes.Panics
This method will panic if this connection is using an h2 protocol.
fn poll_without_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> where S: Unpin, S::Future: Unpin,Poll the connection for completion, but without calling
shutdownon the underlying IO.This is useful to allow running a connection while doing an HTTP upgrade. Once the upgrade is completed, the connection would be "done", but it is not desired to actually shutdown the IO object. Instead you would take it back using
into_parts.fn without_shutdown(self) -> impl Future<Output = Result<Parts<I, S>>>Prevent shutdown of the underlying IO object at the end of service the request, instead run
into_parts. This is a convenience wrapper overpoll_without_shutdown.Error
This errors if the underlying connection protocol is not HTTP/1.
fn with_upgrades(self) -> UpgradeableConnection<I, S> where I: Send,Enable this connection to support higher-level HTTP upgrades.
See the
upgrademodule for more.
Trait Implementations
impl<'__pin, T, S> Unpin for Connection<T, S>
where
PinnedFieldsOf<__Origin<'__pin, T, S>>: Unpin,
S: HttpService<IncomingBody>,
impl<I, B, S> Future for Connection<I, S>
where
S: HttpService<Incoming, ResBody = B>,
S::Error: Into<Box<dyn StdError + Send + Sync>>,
I: Read + Write + Unpin,
B: Body + 'static,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
type Output = Result<(), Error>;fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
impl<I, S> Debug for Connection<I, S>
where
S: HttpService<Incoming>,
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<T, S> !RefUnwindSafe for Connection<T, S>
impl<T, S> !UnwindSafe for Connection<T, S>
impl<T, S> Freeze for Connection<T, S>
where
Dispatcher<Server<S, Incoming>, <S as HttpService<Incoming>>::ResBody, T, Server>: Freeze,
impl<T, S> Send for Connection<T, S>
where
Dispatcher<Server<S, Incoming>, <S as HttpService<Incoming>>::ResBody, T, Server>: Send,
impl<T, S> Sync for Connection<T, S>
where
Dispatcher<Server<S, Incoming>, <S as HttpService<Incoming>>::ResBody, T, Server>: Sync,
impl<T, S> UnsafeUnpin for Connection<T, S>
where
Dispatcher<Server<S, Incoming>, <S as HttpService<Incoming>>::ResBody, T, Server>: UnsafeUnpin,
Blanket Implementations
impl<F> IntoFuture for Connection<T, S>
where
F: Future,
type Output = <F as Future>::Output;type IntoFuture = F;fn into_future(self) -> <F as IntoFuture>::IntoFuture
impl<F, T, E> TryFuture for Connection<T, S>
where
F: Future<Output = Result<T, E>> + ?Sized,
type Ok = T;type Error = E;fn try_poll(self: Pin<&mut F>, cx: &mut Context<'_>) -> Poll<<F as Future>::Output>
impl<T> Any for Connection<T, S>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Connection<T, S>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Connection<T, S>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Connection<T, S>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> FutureExt for Connection<T, S>
where
T: Future + ?Sized,
impl<T> Instrument for Connection<T, S>
impl<T> WithSubscriber for Connection<T, S>
impl<T, U> Into<U> for Connection<T, S>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Connection<T, S>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Connection<T, S>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>