Struct Connection
struct Connection<T, B: Buf> { ... }
Accepts inbound HTTP/2 streams on a connection.
A Connection is backed by an I/O resource (usually a TCP socket) and
implements the HTTP/2 server logic for that connection. It is responsible
for receiving inbound streams initiated by the client as well as driving the
internal state forward.
Connection values are created by calling handshake. Once a
Connection value is obtained, the caller must call poll or
poll_close in order to drive the internal connection state forward.
See module level documentation for more details
Examples
# use ;
# use server;
# use *;
#
# async
#
#
Implementations
impl<T, B> Connection<T, B>
async fn accept(self: &mut Self) -> Option<Result<(Request<RecvStream>, SendResponse<B>), Error>>Accept the next incoming request on this connection.
fn set_target_window_size(self: &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(self: &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 enable_connect_protocol(self: &mut Self) -> Result<(), Error>Enables the extended CONNECT protocol.
Errors
Returns an error if a previous call is still pending acknowledgement from the remote endpoint.
fn poll_closed(self: &mut Self, cx: &mut Context<'_>) -> Poll<Result<(), Error>>Returns
Readywhen the underlying connection has closed.If any new inbound streams are received during a call to
poll_closed, they will be queued and returned on the next call topoll_accept.This function will advance the internal connection state, driving progress on all the other handles (e.g.
RecvStreamandSendStream).See here for more details.
fn abrupt_shutdown(self: &mut Self, reason: Reason)Sets the connection to a GOAWAY state.
Does not terminate the connection. Must continue being polled to close connection.
After flushing the GOAWAY frame, the connection is closed. Any outstanding streams do not prevent the connection from closing. This should usually be reserved for shutting down when something bad external to
h2has happened, and open streams cannot be properly handled.For graceful shutdowns, see
graceful_shutdown.fn graceful_shutdown(self: &mut Self)Starts a graceful shutdown process.
Must continue being polled to close connection.
It's possible to receive more requests after calling this method, since they might have been in-flight from the client already. After about 1 RTT, no new requests should be accepted. Once all active streams have completed, the connection is closed.
fn ping_pong(self: &mut Self) -> Option<PingPong>Takes a
PingPonginstance from the connection.Note
This may only be called once. Calling multiple times will return
None.fn has_streams(self: &Self) -> boolChecks if there are any streams
fn max_concurrent_send_streams(self: &Self) -> usizeReturns the maximum number of concurrent streams that may be initiated by the server on this connection.
This limit is configured by the client 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: &Self) -> usizeReturns the maximum number of concurrent streams that may be initiated by the client 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.
impl<T> Any for Connection<T, B>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Connection<T, B>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Connection<T, B>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Connection<T, B>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Instrument for Connection<T, B>
impl<T> WithSubscriber for Connection<T, B>
impl<T, B> Debug for Connection<T, B>
fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result
impl<T, B> Freeze for Connection<T, B>
impl<T, B> RefUnwindSafe for Connection<T, B>
impl<T, B> Send for Connection<T, B>
impl<T, B> Sync for Connection<T, B>
impl<T, B> Unpin for Connection<T, B>
impl<T, B> UnsafeUnpin for Connection<T, B>
impl<T, B> UnwindSafe for Connection<T, B>
impl<T, U> Into for Connection<T, B>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Connection<T, B>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Connection<T, B>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>