Struct Connection
#[must_use = "futures do nothing unless polled"]
pub struct Connection<T, B: Buf = Bytes> { /* private fields */ }
Manages all state associated with an HTTP/2 client connection.
A Connection is backed by an I/O resource (usually a TCP socket) and
implements the HTTP/2 client logic for that connection. It is responsible
for driving the internal state forward, performing the work requested of the
associated handles (SendRequest, ResponseFuture, SendStream,
RecvStream).
Connection values are created by calling handshake. Once a
Connection value is obtained, the caller must repeatedly call poll
until Ready is returned. The easiest way to do this is to submit the
Connection instance to an executor.
Examples
# use ;
# use client;
# use *;
#
# async # where T: AsyncRead + AsyncWrite + Send + Unpin + 'static,
#
#
#
Implementations
impl<T, B> Connection<T, B>
where
T: AsyncRead + AsyncWrite + Unpin,
B: Buf,
fn set_target_window_size(&mut self, size: u32)Sets the target window size for the whole connection.
If
sizeis greater than the current value, then aWINDOW_UPDATEframe will be immediately sent to the remote, increasing the connection level window bysize - current_value.If
sizeis less than the current value, nothing will happen immediately. However, as window capacity is released byFlowControlinstances, noWINDOW_UPDATEframes will be sent out until the number of "in flight" bytes drops belowsize.The default value is 65,535.
See
FlowControldocumentation for more details.fn set_initial_window_size(&mut self, size: u32) -> Result<(), Error>Set a new
INITIAL_WINDOW_SIZEsetting (in octets) for stream-level flow control for received data.The
SETTINGSwill be sent to the remote, and only applied once the remote acknowledges the change.This can be used to increase or decrease the window size for existing streams.
Errors
Returns an error if a previous call is still pending acknowledgement from the remote endpoint.
fn ping_pong(&mut self) -> Option<PingPong>Takes a
PingPonginstance from the connection.Note
This may only be called once. Calling multiple times will return
None.fn max_concurrent_send_streams(&self) -> usizeReturns the maximum number of concurrent streams that may be initiated by this client.
This limit is configured by the server peer by sending the
SETTINGS_MAX_CONCURRENT_STREAMSparameter in aSETTINGSframe. This method returns the currently acknowledged value received from the remote.fn max_concurrent_recv_streams(&self) -> usizeReturns the maximum number of concurrent streams that may be initiated by the server on this connection.
This returns the value of the
SETTINGS_MAX_CONCURRENT_STREAMSparameter sent in aSETTINGSframe that has been acknowledged by the remote peer. The value to be sent is configured by theBuilder::max_concurrent_streamsmethod before handshaking with the remote peer.
Trait Implementations
impl<T, B> Debug for Connection<T, B>
where
T: AsyncRead + AsyncWrite + Debug,
B: Debug + Buf,
fn fmt(&self, fmt: &mut Formatter<'_>) -> Result
impl<T, B> Future for Connection<T, B>
where
T: AsyncRead + AsyncWrite + Unpin,
B: Buf,
type Output = Result<(), Error>;fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
Auto Trait Implementations
impl<T, B = Bytes> !Freeze for Connection<T, B>
impl<T, B = Bytes> !RefUnwindSafe for Connection<T, B>
impl<T, B = Bytes> !UnwindSafe for Connection<T, B>
impl<T, B> Send for Connection<T, B>
where
Connection<T, Peer, B>: Send,
impl<T, B> Sync for Connection<T, B>
where
Connection<T, Peer, B>: Sync,
impl<T, B> Unpin for Connection<T, B>
where
Connection<T, Peer, B>: Unpin,
impl<T, B> UnsafeUnpin for Connection<T, B>
where
Connection<T, Peer, B>: 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) -> TReturns 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) -> 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, 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>