Skip to main content

Transport

Enum Transport 

Source
pub enum Transport {
    Quic(QuicTransport),
}
Expand description

A transport-agnostic connection (QUIC or WebTransport).

Variants§

§

Quic(QuicTransport)

Raw QUIC via quinn.

Implementations§

Source§

impl Transport

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, ) -> Option<impl Future<Output = TransportError> + Send + 'static>

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

Borrows nothing and outlives this transport, so a caller can take it before handing the transport to a handshake and still be holding it when the peer’s answer lands. That ordering is the whole point: a peer refusing a setup often finishes the control stream first and closes the session a round trip later, by which time the handshake has already returned end-of-stream and dropped everything it had.

None over WebTransport. The session close there is wtransport’s and its code is in a private field with no accessor — the first of the README’s known gaps, not a decision made here.

Source

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

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

Empty when there is none to report — the handshake has not completed, the peer sent no chain — rather than an error, because none of those are failures of this connection.

This is the whole of the certificate API, and that is deliberate. The bytes are handed over exactly as the peer sent them and nothing here parses them, dates them, or decides whether they are trustworthy. A certificate verdict is a judgement about what the caller is trying to establish: a probe grading a public relay wants to know whether the chain reaches a public root, an operator running against their own CA wants precisely the opposite answer to count as healthy, and a library that picked one would be silently wrong for the other. Whoever knows the question owns the answer; this owns the evidence.

One consequence worth naming, because it is the finding this exists to make visible: the length of what comes back is itself a measurement. A relay that serves a leaf and no intermediate hands back a chain of one, which a client validating against a fixed root set rejects while a browser holding a cached intermediate connects to it happily. That is a misconfiguration and not a mystery — but only to a caller that can see how many certificates arrived, which is why the chain is returned whole rather than as a leaf.

Read off the live connection each time — nothing is cached — so a caller that intends to keep the chain must take it while it still holds the Transport. Closing does not by itself erase the answer (quinn keeps the crypto session for the handle’s lifetime), but dropping the handle does, and a caller that closes by value has done both.

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