Struct Connection

#[must_use = "futures do nothing unless polled"]
pub struct Connection<T, B>
where
    T: Read + Write,
    B: Body + 'static, { /* private fields */ }

A future that processes all HTTP state for the IO object.

In most cases, this should just be spawned into an executor, so that it can process incoming and outgoing messages, notice hangups, and the like.

Instances of this type are typically created via the handshake function.

Drop behavior

Dropping the Connection will close the underlying IO resource. Any in-flight requests that have not received a response will be interrupted. If graceful shutdown is desired, poll the connection until it completes instead of dropping.

Implementations

impl<T, B> Connection<T, B> where T: Read + Write + Unpin + Send, B: Body + 'static, B::Error: Into<Box<dyn StdError + Send + Sync>>,

fn with_upgrades(self) -> UpgradeableConnection<T, B>

Enable this connection to support higher-level HTTP upgrades.

See the upgrade module for more.

impl<T, B> Connection<T, B> where T: Read + Write + Unpin, B: Body + 'static, B::Error: Into<Box<dyn StdError + Send + Sync>>,

fn into_parts(self) -> Parts<T>

Return the inner IO object, and additional information.

Only works for HTTP/1 connections. HTTP/2 connections will panic.

fn poll_without_shutdown(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>

Poll the connection for completion, but without calling shutdown on 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.

Use poll_fn and try_ready! to work with this function; or use the without_shutdown wrapper.

async fn without_shutdown(self) -> Result<Parts<T>>

Prevent shutdown of the underlying IO object at the end of service the request, instead run into_parts. This is a convenience wrapper over poll_without_shutdown.

Trait Implementations

impl<T, B> Debug for Connection<T, B> where T: Read + Write + Debug, B: Body + 'static,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T, B> Future for Connection<T, B> where T: Read + Write + Unpin, B: Body + 'static, B::Data: Send, B::Error: Into<Box<dyn StdError + Send + Sync>>,

type Output = Result<(), Error>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Auto Trait Implementations

impl<T, B> !RefUnwindSafe for Connection<T, B>

impl<T, B> !UnwindSafe for Connection<T, B>

impl<T, B> Freeze for Connection<T, B> where Dispatcher<Client<B>, B, T, Client>: Freeze,

impl<T, B> Send for Connection<T, B> where Dispatcher<Client<B>, B, T, Client>: Send,

impl<T, B> Sync for Connection<T, B> where Dispatcher<Client<B>, B, T, Client>: Sync,

impl<T, B> Unpin for Connection<T, B> where Dispatcher<Client<B>, B, T, Client>: Unpin,

impl<T, B> UnsafeUnpin for Connection<T, B> where Dispatcher<Client<B>, B, T, Client>: UnsafeUnpin,

Blanket Implementations

impl<F> IntoFuture for Connection<T, B> 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, B> 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, B> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Connection<T, B> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Connection<T, B> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Connection<T, B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FutureExt for Connection<T, B> where T: Future + ?Sized,

impl<T> Instrument for Connection<T, B>

impl<T> WithSubscriber for Connection<T, B>

impl<T, U> Into<U> for Connection<T, B> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Connection<T, B> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Connection<T, B> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>