Skip to main content

H2Connection

Struct H2Connection 

Source
pub struct H2Connection { /* private fields */ }
Expand description

The HTTP/2 connection handle. Cheap to clone (shares one Rc state).

Implementations§

Source§

impl H2Connection

Source

pub fn is_closed(&self) -> bool

True once the connection has been torn down.

Source

pub fn active_streams(&self) -> usize

Client-initiated streams currently open or half-closed — the ones that count toward the peer’s SETTINGS_MAX_CONCURRENT_STREAMS (§5.1.2).

Source

pub fn can_open_stream(&self) -> bool

True if a new request would stay within the peer’s advertised SETTINGS_MAX_CONCURRENT_STREAMS. A connection pool uses this to decide whether to route here or open a fresh connection; a direct caller need not check — request parks until a slot frees.

Source

pub async fn request(&self, init: RequestInit) -> Result<Response, H2Error>

The negotiated WebSocket subprotocol, if opened via a WebSocket (set by the caller). Empty otherwise.

Source

pub async fn ping(&self) -> Result<f64, H2Error>

Send a PING and resolve with the round-trip time in milliseconds.

Source

pub fn close(&self)

Gracefully close: send GOAWAY, then tear down.

Trait Implementations§

Source§

impl Clone for H2Connection

Source§

fn clone(&self) -> H2Connection

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl PoolConnection for H2Connection

Source§

fn is_closed(&self) -> bool

Whether the connection has been torn down.
Source§

fn can_open_stream(&self) -> bool

Whether a new request would stay within the peer’s advertised SETTINGS_MAX_CONCURRENT_STREAMS.
Source§

fn request( &self, init: RequestInit, ) -> LocalBoxFuture<'static, Result<Response, H2Error>>

Issue a request on this connection.
Source§

fn close(&self)

Gracefully close the connection.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.