Skip to main content

Connection

Struct Connection 

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

A QUIC connection driven by a crate::Worker, usable as a MoQ transport.

Created by Endpoint (or its client::connect / server::accept shorthands), already established. Clones share the connection; each carries its own parking so concurrent pending operations don’t trample each other’s wakeups. Dropping every handle (and every stream) drops the driver’s Rc peers, but the driver itself keeps the connection alive until it ends; close explicitly with close (which moq’s session machine does).

That close only records the code: the driver task is what frames the CONNECTION_CLOSE and hands it to the socket. Drive the worker until poll_closed resolves before stopping it, or the packet is never built and the peer idles out instead.

Implementations§

Source§

impl Connection

Source

pub fn peer_chain(&self) -> Option<Vec<Vec<u8>>>

The peer’s certificate chain in DER, leaf first, or None if it presented none.

A server only sees one when it asked (ClientAuth), and TLS already validated it against the configured roots by the time this connection exists: an invalid chain fails the handshake instead. So a Some here is an authenticated peer, and the chain is what names it.

Source

pub fn remote_addr(&self) -> SocketAddr

The peer’s address as of the handshake; a peer that migrates later keeps its connection but not this value.

Source

pub fn server_name(&self) -> Option<&str>

The SNI the client presented, or None if it sent none. Always None on a dialed connection.

Trait Implementations§

Source§

impl Clone for Connection

Source§

fn clone(&self) -> Self

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Session for Connection

Source§

type SendStream = SendStream

The outgoing stream type. Only the poll half is required, so a !Send session can hang !Send streams off it.
Source§

type RecvStream = RecvStream

The incoming stream type. Only the poll half is required, so a !Send session can hang !Send streams off it.
Source§

type Error = Error

The error type for every operation on this session.
Source§

fn poll_accept_uni( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<Self::RecvStream, Self::Error>>

Poll for a unidirectional stream created by the peer.
Source§

fn poll_accept_bi( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::SendStream, Self::RecvStream), Self::Error>>

Poll for a bidirectional stream created by the peer.
Source§

fn poll_open_uni( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<Self::SendStream, Self::Error>>

Poll to open a unidirectional stream, which blocks while there are too many concurrent streams.
Source§

fn poll_open_bi( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::SendStream, Self::RecvStream), Self::Error>>

Poll to open a bidirectional stream, which blocks while there are too many concurrent streams.
Source§

fn poll_send_datagram( &mut self, cx: &mut Context<'_>, payload: &[u8], ) -> Poll<Result<(), Self::Error>>

Poll to send a datagram over the network. Read more
Source§

fn poll_recv_datagram( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<Bytes, Self::Error>>

Poll for a datagram from the network.
Source§

fn max_datagram_size(&self) -> usize

The maximum size of a datagram that can be sent.
Source§

fn protocol(&self) -> Option<&str>

Return the application protocol negotiated for this session, if any. Read more
Source§

fn close(&mut self, code: u32, reason: &str)

Close the connection immediately with a code and reason. Read more
Source§

fn poll_closed(&mut self, cx: &mut Context<'_>) -> Poll<Self::Error>

Poll until the connection is closed by either side.
Source§

fn stats(&self) -> impl Stats

Return connection-level statistics. 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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<S> Session for S
where S: Session + Clone + 'static, <S as Session>::SendStream: SendStream, <S as Session>::RecvStream: RecvStream,

Source§

fn accept_uni(&mut self) -> AcceptUni<'_, Self> ⓘ

Accept the next unidirectional stream opened by the peer.
Source§

fn accept_bi(&mut self) -> AcceptBi<'_, Self> ⓘ

Accept the next bidirectional stream opened by the peer.
Source§

fn open_uni(&mut self) -> OpenUni<'_, Self> ⓘ

Open a unidirectional stream, waiting for stream credit if necessary.
Source§

fn open_bi(&mut self) -> OpenBi<'_, Self> ⓘ

Open a bidirectional stream, waiting for stream credit if necessary.
Source§

fn recv_datagram(&mut self) -> RecvDatagram<'_, Self> ⓘ

Receive the next datagram from the peer.
Source§

fn send_datagram(&mut self, payload: &[u8]) -> Result<(), Self::Error>

Send a datagram, best-effort: if the transport has no room for it right now, the datagram is dropped, exactly as the network is allowed to do.
Source§

fn closed(&mut self) -> SessionClosed<'_, Self> ⓘ

Wait until the session is closed by either side, returning the reason.
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more