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_groupreturns aSendGroup. iroh schedules streams by an urgency alone, so a group’s priority and each stream’s order in it are packed into the urgency; seeSendGroupfor the mapping and where it departs from kuic’s.wireholds the UDP byte counts and the bytes declared lost, refreshed from the connection statistics whenever moq-net readsmetrics. iroh reports neither the time sends waited on congestion control nor flow-control stalls, so those counters stay zero.probeisNone: iroh’s congestion controller takes no probe target.receive_windowisNone: iroh does not report the receive windows in force. moq-net then never pauses a stream.
Implementations§
Source§impl Transport
impl Transport
Sourcepub fn new(connection: Connection) -> Result<Self, Error>
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.
Sourcepub async fn connect(
endpoint: &Endpoint,
peer: impl Into<EndpointAddr>,
) -> Result<Self, Error>
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.
Sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
Returns the iroh connection the transport runs over.
Trait Implementations§
Source§impl Session for Transport
impl Session for Transport
Source§fn send_datagram(
&self,
payload: Bytes,
_options: SendOptions<'_, SendGroup>,
) -> Result<(), TransportError>
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
type SendStream = SendStream
Source§type RecvStream = Buffered<RecvStream>
type RecvStream = Buffered<RecvStream>
Source§type Error = TransportError
type Error = TransportError
Source§fn poll_accept_uni(
&self,
waiter: &Waiter,
) -> Poll<Result<Self::RecvStream, TransportError>>
fn poll_accept_uni( &self, waiter: &Waiter, ) -> Poll<Result<Self::RecvStream, TransportError>>
Source§fn poll_accept_bi(
&self,
waiter: &Waiter,
) -> Poll<Result<BiStreams<Self>, TransportError>>
fn poll_accept_bi( &self, waiter: &Waiter, ) -> Poll<Result<BiStreams<Self>, TransportError>>
Source§fn poll_open_uni(
&self,
waiter: &Waiter,
options: SendOptions<'_, SendGroup>,
) -> Poll<Result<SendStream, TransportError>>
fn poll_open_uni( &self, waiter: &Waiter, options: SendOptions<'_, SendGroup>, ) -> Poll<Result<SendStream, TransportError>>
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>>
fn poll_open_bi( &self, waiter: &Waiter, options: SendOptions<'_, SendGroup>, ) -> Poll<Result<BiStreams<Self>, TransportError>>
options, which
blocks while there are too many concurrent streams.Source§fn send_group(&self, priority: i64) -> Option<SendGroup>
fn send_group(&self, priority: i64) -> Option<SendGroup>
priority, or None when the transport orders streams by
their own priority alone. Read moreSource§fn poll_recv_datagram(
&self,
waiter: &Waiter,
) -> Poll<Result<Bytes, TransportError>>
fn poll_recv_datagram( &self, waiter: &Waiter, ) -> Poll<Result<Bytes, TransportError>>
Source§fn max_datagram_size(&self) -> usize
fn max_datagram_size(&self) -> usize
Source§fn protocol(&self) -> Option<&str>
fn protocol(&self) -> Option<&str>
Source§fn close(&self, code: u32, reason: &str)
fn close(&self, code: u32, reason: &str)
Source§fn poll_closed(&self, waiter: &Waiter) -> Poll<TransportError>
fn poll_closed(&self, waiter: &Waiter) -> Poll<TransportError>
Source§fn metrics(&self) -> impl Metrics
fn metrics(&self) -> impl Metrics
Source§fn wire(&self) -> Option<Wire>
fn wire(&self) -> Option<Wire>
None when it tracks none.Source§fn probe(&self) -> Option<Probe>
fn probe(&self) -> Option<Probe>
None when it has no sender. Read moreSource§fn receive_window(&self) -> Option<ReceiveWindow>
fn receive_window(&self) -> Option<ReceiveWindow>
None when the transport cannot say. Read moreSource§fn reliable_reset(&self) -> bool
fn reliable_reset(&self) -> bool
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>
fn set_limits(&self, limits: Limits) -> Result<(), LimitsError>
limits to the live session, such as to open the receive window a server held
back until it admitted the peer. Read moreSource§fn set_keep_alive(&self, keep_alive: KeepAlive) -> Result<(), KeepAliveError>
fn set_keep_alive(&self, keep_alive: KeepAlive) -> Result<(), KeepAliveError>
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 moreSource§fn poll_liveness(&self, waiter: &Waiter, last: Liveness) -> Poll<Liveness>
fn poll_liveness(&self, waiter: &Waiter, last: Liveness) -> Poll<Liveness>
last, returning it. Pending forever
without a keep-alive.Source§fn accept_uni(&self) -> AcceptUni<'_, Self> ⓘ
fn accept_uni(&self) -> AcceptUni<'_, Self> ⓘ
Source§fn accept_bi(&self) -> AcceptBi<'_, Self> ⓘ
fn accept_bi(&self) -> AcceptBi<'_, Self> ⓘ
Source§fn open_uni<'a>(
&'a self,
options: SendOptions<'a, <Self::SendStream as SendStream>::Group>,
) -> OpenUni<'a, Self> ⓘ
fn open_uni<'a>( &'a self, options: SendOptions<'a, <Self::SendStream as SendStream>::Group>, ) -> OpenUni<'a, Self> ⓘ
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> ⓘ
fn open_bi<'a>( &'a self, options: SendOptions<'a, <Self::SendStream as SendStream>::Group>, ) -> OpenBi<'a, Self> ⓘ
options, waiting for
stream credit if necessary.