Skip to main content

Transport

Struct Transport 

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

moq-net’s poll transport over one iroh connection.

Implements moq_net::transport::poll::Session on iroh’s QUIC connection and streams directly. The request path and token travel in the MoQ SETUP, since raw QUIC has no request URI.

What it can and cannot back:

  • send_group returns a SendGroup. iroh schedules streams by an urgency alone, so a group’s priority and each stream’s order in it are packed into the urgency; see SendGroup for the mapping and where it departs from kuic’s.
  • wire holds the UDP byte counts and the bytes declared lost, refreshed from the connection statistics whenever moq-net reads metrics. iroh reports neither the time sends waited on congestion control nor flow-control stalls, so those counters stay zero.
  • probe is None: iroh’s congestion controller takes no probe target.
  • receive_window is None: iroh does not report the receive windows in force. moq-net then never pauses a stream.

Implementations§

Source§

impl Transport

Source

pub fn new(connection: Connection) -> Result<Self, Error>

Wraps an incoming or outgoing connection that negotiated a MoQ ALPN.

Hand the transport to moq_net::Server::handshake for an accepted connection, or to moq_net::Client::connect for a dialed one. To dial with iroh’s connect options, such as another QUIC transport config for this one connection while the endpoint keeps its own for every other, connect through iroh and wrap the result:

use iroh::endpoint::ConnectOptions;
use moq_transport_iroh::{ALPN, Transport};

let options = ConnectOptions::new().with_transport_config(config);
let connection = endpoint.connect_with_opts(peer, ALPN, options).await?.await?;
let transport = Transport::new(connection)?;
§Errors

Fails with Error::UnsupportedAlpn if the connection negotiated an ALPN this build does not speak, which happens when a handler is mounted under an ALPN outside alpns.

Source

pub async fn connect( endpoint: &Endpoint, peer: impl Into<EndpointAddr>, ) -> Result<Self, Error>

Dials peer and returns the MoQ transport over the connection.

Offers only ALPN, the newest MoQ version. iroh’s Router sorts the ALPNs it accepts, and TLS picks the first of the server’s that the client offers, so offering older versions too would settle every dial on the oldest moq-lite. Hand the transport to moq_net::Client::connect.

Dropping the future abandons the dial.

use moq_transport_iroh::Transport;

let transport = Transport::connect(&endpoint, peer).await?;
§Errors

Fails with Error::Connect if the dial fails, or with Error::UnsupportedAlpn if the peer negotiates an ALPN this build does not speak.

Source

pub fn connection(&self) -> &Connection

Returns the iroh connection the transport runs over.

Trait Implementations§

Source§

impl Debug for Transport

Source§

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

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

impl Session for Transport

Source§

fn send_datagram( &self, payload: Bytes, _options: SendOptions<'_, SendGroup>, ) -> Result<(), TransportError>

Sends payload, ignoring options: iroh queues datagrams apart from streams and cannot rank one against the other.

Source§

type SendStream = SendStream

The outgoing stream type.
Source§

type RecvStream = Buffered<RecvStream>

The incoming stream type.
Source§

type Error = TransportError

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

fn poll_accept_uni( &self, waiter: &Waiter, ) -> Poll<Result<Self::RecvStream, TransportError>>

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

fn poll_accept_bi( &self, waiter: &Waiter, ) -> Poll<Result<BiStreams<Self>, TransportError>>

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

fn poll_open_uni( &self, waiter: &Waiter, options: SendOptions<'_, SendGroup>, ) -> Poll<Result<SendStream, TransportError>>

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

fn poll_open_bi( &self, waiter: &Waiter, options: SendOptions<'_, SendGroup>, ) -> Poll<Result<BiStreams<Self>, TransportError>>

Poll to open a bidirectional stream, its sending half scheduled by options, which blocks while there are too many concurrent streams.
Source§

fn send_group(&self, priority: i64) -> Option<SendGroup>

Open a send group at priority, or None when the transport orders streams by their own priority alone. Read more
Source§

fn poll_recv_datagram( &self, waiter: &Waiter, ) -> Poll<Result<Bytes, TransportError>>

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 address(&self) -> Address

Return where this transport carries the request target.
Source§

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

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

fn poll_closed(&self, waiter: &Waiter) -> Poll<TransportError>

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

fn metrics(&self) -> impl Metrics

Return connection-level metrics; by default, none are tracked.
Source§

fn wire(&self) -> Option<Wire>

Return the wire counters this transport updates, or None when it tracks none.
Source§

fn probe(&self) -> Option<Probe>

Return the target this transport’s sender probes up to, or None when it has no sender. Read more
Source§

fn receive_window(&self) -> Option<ReceiveWindow>

Return the receive windows now in force, or None when the transport cannot say. Read more
Source§

fn reliable_reset(&self) -> bool

Whether SendStream::reset_at still delivers its prefix to the peer’s reader, such as over raw QUIC with RESET_STREAM_AT negotiated, but never over WebTransport, whose browser API may discard it anyway. A plain RESET_STREAM lets the peer discard bytes it has not read, even acknowledged ones, so the default is false.
Source§

fn set_limits(&self, limits: Limits) -> Result<(), LimitsError>

Apply limits to the live session, such as to open the receive window a server held back until it admitted the peer. Read more
Source§

fn set_keep_alive(&self, keep_alive: KeepAlive) -> Result<(), KeepAliveError>

Start keep_alive: probe the peer once half of its soft passes unheard, report it Stale through poll_liveness once all of soft does, and close as an idle timeout once hard does. Any packet the peer sends counts as hearing it, so a busy session sends no probe. A peer already unheard for soft when this is called is reported stale at once. Read more
Source§

fn poll_liveness(&self, waiter: &Waiter, last: Liveness) -> Poll<Liveness>

Poll until the peer’s liveness differs from last, returning it. Pending forever without a keep-alive.
Source§

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

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

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

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

fn open_uni<'a>( &'a self, options: SendOptions<'a, <Self::SendStream as SendStream>::Group>, ) -> OpenUni<'a, Self> ⓘ

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

fn open_bi<'a>( &'a self, options: SendOptions<'a, <Self::SendStream as SendStream>::Group>, ) -> OpenBi<'a, Self> ⓘ

Open a bidirectional stream, its sending half scheduled by options, waiting for stream credit if necessary.
Source§

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

Receive the next datagram from the peer.
Source§

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

Wait until the session is closed by either side, returning the reason.

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<S> Boxable for S

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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