Skip to main content

Connection

Struct Connection 

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

A QUIC connection.

Implementations§

Source§

impl Connection

Source

pub fn new() -> Self

Creates a new in-memory loopback connection.

Source

pub fn from_udp(socket: Arc<UdpSocket>, remote_addr: SocketAddr) -> Self

Creates a connection wrapping an existing UDP socket.

Source

pub fn from_datagrams( socket: Arc<UdpSocket>, remote_addr: SocketAddr, rx: UnboundedReceiver<Bytes>, ) -> Self

Creates a connection from a datagram receiver.

Source

pub fn remote_address(&self) -> Option<SocketAddr>

Returns the peer address for this connection.

Source

pub fn local_address(&self) -> Option<SocketAddr>

Returns the local socket address for this connection.

Source

pub fn is_closed(&self) -> bool

Returns whether the connection has been closed.

Source

pub fn connection_id(&self) -> ConnectionId

Returns the active Connection ID (RFC 9000 §5.1).

Source

pub async fn stats(&self) -> ConnectionStats

Returns snapshot statistics for this connection (RFC 9002 §5).

Source

pub async fn rtt(&self) -> Duration

Returns the current smoothed RTT estimate.

Source

pub async fn congestion_window(&self) -> u64

Returns the current congestion window size in bytes.

Source

pub fn max_datagram_size(&self) -> usize

Returns the maximum datagram payload size in bytes that can be sent without fragmentation (RFC 9221 §5).

Source

pub async fn handshake_data(&self) -> Option<HandshakeData>

Returns TLS 1.3 handshake metadata (ALPN, server name, cipher suite).

Source

pub async fn peer_identity(&self) -> Option<Vec<CertificateDer<'static>>>

Returns the validated client/peer certificate chain if mutual TLS (mTLS) was used.

Source

pub fn set_max_concurrent_uni_streams(&self, n: u64)

Sets the maximum concurrent unidirectional streams allowed by this endpoint (RFC 9000 §19.11).

Source

pub fn set_max_concurrent_bi_streams(&self, n: u64)

Sets the maximum concurrent bidirectional streams allowed by this endpoint (RFC 9000 §19.11).

Source

pub async fn open_bi(&self) -> Result<(SendStream, RecvStream)>

Opens a locally-initiated bidirectional stream (RFC 9000 §2.1).

Source

pub async fn open_uni(&self) -> Result<SendStream>

Opens a locally-initiated unidirectional stream (RFC 9000 §2.1).

Source

pub async fn accept_bi(&self) -> Result<(SendStream, RecvStream)>

Accepts the next incoming bidirectional stream opened by the peer.

Source

pub async fn accept_uni(&self) -> Result<RecvStream>

Accepts the next incoming unidirectional stream opened by the peer.

Source

pub async fn send_datagram(&self, data: Bytes) -> Result<()>

Sends an unreliable QUIC datagram (RFC 9221).

Source

pub async fn send_datagram_wait(&self, data: Bytes) -> Result<()>

Blocks until datagram send buffer has capacity and transmits the datagram.

Source

pub async fn recv_datagram(&self) -> Result<Bytes>

Receives the next UDP datagram from this connection’s peer.

Source

pub async fn ingest_frames(&self, payload: &[u8]) -> Result<()>

Decodes a QUIC frame payload and queues DATAGRAM and STREAM frames.

Source

pub async fn close_with(&self, code: u64, reason: &[u8])

Gracefully closes the connection with an application error code and reason phrase (RFC 9000 §10.2).

Source

pub async fn close(&self)

Closes the connection immediately.

Source

pub async fn closed(&self) -> ConnectionCloseInfo

Returns a Future that resolves when the connection is closed, yielding termination details.

Source

pub async fn close_reason(&self) -> Option<ConnectionCloseInfo>

Returns the reason why the connection closed, if it is closed.

Trait Implementations§

Source§

impl Clone for Connection

Source§

fn clone(&self) -> Connection

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 Default for Connection

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V