pub struct Connection { /* private fields */ }Expand description
A QUIC connection.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn from_udp(socket: Arc<UdpSocket>, remote_addr: SocketAddr) -> Self
pub fn from_udp(socket: Arc<UdpSocket>, remote_addr: SocketAddr) -> Self
Creates a connection wrapping an existing UDP socket.
Sourcepub fn from_datagrams(
socket: Arc<UdpSocket>,
remote_addr: SocketAddr,
rx: UnboundedReceiver<Bytes>,
) -> Self
pub fn from_datagrams( socket: Arc<UdpSocket>, remote_addr: SocketAddr, rx: UnboundedReceiver<Bytes>, ) -> Self
Creates a connection from a datagram receiver.
Sourcepub fn remote_address(&self) -> Option<SocketAddr>
pub fn remote_address(&self) -> Option<SocketAddr>
Returns the peer address for this connection.
Sourcepub fn local_address(&self) -> Option<SocketAddr>
pub fn local_address(&self) -> Option<SocketAddr>
Returns the local socket address for this connection.
Sourcepub fn connection_id(&self) -> ConnectionId
pub fn connection_id(&self) -> ConnectionId
Returns the active Connection ID (RFC 9000 §5.1).
Sourcepub async fn stats(&self) -> ConnectionStats
pub async fn stats(&self) -> ConnectionStats
Returns snapshot statistics for this connection (RFC 9002 §5).
Sourcepub async fn congestion_window(&self) -> u64
pub async fn congestion_window(&self) -> u64
Returns the current congestion window size in bytes.
Sourcepub fn max_datagram_size(&self) -> usize
pub fn max_datagram_size(&self) -> usize
Returns the maximum datagram payload size in bytes that can be sent without fragmentation (RFC 9221 §5).
Sourcepub async fn handshake_data(&self) -> Option<HandshakeData>
pub async fn handshake_data(&self) -> Option<HandshakeData>
Returns TLS 1.3 handshake metadata (ALPN, server name, cipher suite).
Sourcepub async fn peer_identity(&self) -> Option<Vec<CertificateDer<'static>>>
pub async fn peer_identity(&self) -> Option<Vec<CertificateDer<'static>>>
Returns the validated client/peer certificate chain if mutual TLS (mTLS) was used.
Sourcepub fn set_max_concurrent_uni_streams(&self, n: u64)
pub fn set_max_concurrent_uni_streams(&self, n: u64)
Sets the maximum concurrent unidirectional streams allowed by this endpoint (RFC 9000 §19.11).
Sourcepub fn set_max_concurrent_bi_streams(&self, n: u64)
pub fn set_max_concurrent_bi_streams(&self, n: u64)
Sets the maximum concurrent bidirectional streams allowed by this endpoint (RFC 9000 §19.11).
Sourcepub async fn open_bi(&self) -> Result<(SendStream, RecvStream)>
pub async fn open_bi(&self) -> Result<(SendStream, RecvStream)>
Opens a locally-initiated bidirectional stream (RFC 9000 §2.1).
Sourcepub async fn open_uni(&self) -> Result<SendStream>
pub async fn open_uni(&self) -> Result<SendStream>
Opens a locally-initiated unidirectional stream (RFC 9000 §2.1).
Sourcepub async fn accept_bi(&self) -> Result<(SendStream, RecvStream)>
pub async fn accept_bi(&self) -> Result<(SendStream, RecvStream)>
Accepts the next incoming bidirectional stream opened by the peer.
Sourcepub async fn accept_uni(&self) -> Result<RecvStream>
pub async fn accept_uni(&self) -> Result<RecvStream>
Accepts the next incoming unidirectional stream opened by the peer.
Sourcepub async fn send_datagram(&self, data: Bytes) -> Result<()>
pub async fn send_datagram(&self, data: Bytes) -> Result<()>
Sends an unreliable QUIC datagram (RFC 9221).
Sourcepub async fn send_datagram_wait(&self, data: Bytes) -> Result<()>
pub async fn send_datagram_wait(&self, data: Bytes) -> Result<()>
Blocks until datagram send buffer has capacity and transmits the datagram.
Sourcepub async fn recv_datagram(&self) -> Result<Bytes>
pub async fn recv_datagram(&self) -> Result<Bytes>
Receives the next UDP datagram from this connection’s peer.
Sourcepub async fn ingest_frames(&self, payload: &[u8]) -> Result<()>
pub async fn ingest_frames(&self, payload: &[u8]) -> Result<()>
Decodes a QUIC frame payload and queues DATAGRAM and STREAM frames.
Sourcepub async fn close_with(&self, code: u64, reason: &[u8])
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).
Sourcepub async fn closed(&self) -> ConnectionCloseInfo
pub async fn closed(&self) -> ConnectionCloseInfo
Returns a Future that resolves when the connection is closed, yielding termination details.
Sourcepub async fn close_reason(&self) -> Option<ConnectionCloseInfo>
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
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more