Skip to main content

QuicTransport

Struct QuicTransport 

Source
pub struct QuicTransport {
    conn: Connection,
}
Expand description

QUIC transport wrapping a quinn::Connection.

Fields§

§conn: Connection

Implementations§

Source§

impl QuicTransport

Source

pub fn new(conn: Connection) -> Self

Create a new QUIC transport from a quinn connection.

Source

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

Open a bidirectional stream.

Source

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

Accept an incoming bidirectional stream.

Source

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

Open a unidirectional send stream.

Source

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

Accept an incoming unidirectional stream.

Source

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

Send a datagram.

Source

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

Receive a datagram.

Source

pub fn close(&self, code: u32, reason: &[u8])

Close the connection.

Source

pub fn closed(&self) -> impl Future<Output = TransportError> + Send + 'static

A future resolving when the session ends, carrying the peer’s close.

Borrows nothing and outlives this transport, for the same reason SendStream::stopped does: the answer arrives after the call that wanted it has already returned. A peer refusing a handshake commonly finishes the control stream first and closes the session a round trip later, so the caller sees an end-of-stream, hands back an error, and drops the transport before the code it was refused with ever lands. Taking this handle before the transport is given away is what makes that code readable at all.

Holding the future keeps the connection alive; dropping it lets quinn close as usual.

Source

pub fn peer_certificates(&self) -> Vec<Vec<u8>>

The certificate chain the peer presented, DER-encoded, leaf first.

Bytes, and no opinion about them: nothing here parses a certificate, checks a date, or decides whether a chain is trustworthy, because the verdict depends on what the caller is measuring. Empty is not an error — a chain is absent for ordinary reasons, including a handshake that has not completed.

A chain that a handshake failed over never reaches here, since there is no connection left to read it off; that is what QuicDialOptions::observing is for.

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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