pub struct Client { /* private fields */ }Expand description
A MoQ client session builder.
Implementations§
Source§impl Client
impl Client
Sourcepub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
pub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
Publish local broadcasts to the remote: the session reads from the given
origin (pass an origin::Producer or origin::Consumer by reference) and
forwards its announcements. Omit to publish nothing.
Sourcepub fn with_subscriber(self, subscribe: Producer) -> Self
pub fn with_subscriber(self, subscribe: Producer) -> Self
Subscribe to remote broadcasts: the session writes the broadcasts the
remote announces into this origin::Producer. Omit to subscribe to nothing.
Sourcepub fn with_stats(self, stats: Session) -> Self
pub fn with_stats(self, stats: Session) -> Self
Attach a per-connection stats::Session context. The session’s publish
(egress) and subscribe (ingress) origin handles are tagged with it, so all
traffic counters are attributed through the model for this session’s lifetime.
Pass stats::Session::default (a no-op context) to opt out.
Sourcepub fn with_origin(self, origin: Producer) -> Self
pub fn with_origin(self, origin: Producer) -> Self
Set both publish and subscribe from one shared origin::Producer.
Equivalent to with_publisher and
with_subscriber with the same origin.
Sourcepub fn with_versions(self, versions: Versions) -> Self
pub fn with_versions(self, versions: Versions) -> Self
Restrict which protocol versions to offer, in preference order. Defaults to every version this crate supports.
Sourcepub fn with_path(self, path: impl Into<String>) -> Self
pub fn with_path(self, path: impl Into<String>) -> Self
Set the request path to advertise in SETUP (moq-lite-05 and newer, and every moq-transport draft we speak).
Only for transports that carry no request URI of their own (native QUIC, qmux
over TCP/TLS, unix sockets), so the server learns which path the client wants.
Append ? and the URI query when there is one: that is how a credential in the
query (?jwt=) reaches the server.
Bindings that already carry a URI (WebTransport, qmux over WebSocket) convey
the path there and MUST NOT send this; a server is entitled to treat it as a
protocol violation. An empty path is equivalent to omitting it. Ignored by
versions with no in-band request path (lite 01-04).
Set the URI authority to advertise in SETUP (moq-transport only)
Sourcepub fn with_cost(self, cost: u64) -> Self
pub fn with_cost(self, cost: u64) -> Self
Price this link, in the units the rest of the mesh uses (moq-lite-06+, and
moqt-17+ via the MoQ Cluster extension).
The dialer is the side that knows what a link costs, because it chose the peer:
use 0 for a sibling in the same datacenter and something large for another
region across a metered backbone. So this prices both directions. We add it to
the route cost of every announcement the peer sends us, and declare it in our
SETUP so the peer adds it to every announcement we send, which is what a server
accepting an anonymous connection needs: it cannot tell a sibling from a
stranger, so it has no price of its own to apply.
A price the peer declares applies only where we set none. An unpriced link costs
1, which makes the cost track the hop count and so reproduces plain
shortest-path routing.
Sourcepub fn with_peer_hop(self, hop: Hop) -> Self
pub fn with_peer_hop(self, hop: Hop) -> Self
Assign the identity this peer’s routes are attributed to, overriding the fresh per-dial default.
A dialed session whose peer declares no hop gets a random one for that connection, the same way an accepted session does. That keeps a route learned from the peer off the session that learned it, and keeps a SUBSCRIBE that arrives on it from being routed back to it. An identity the peer declares on the wire still wins.
Pass an id only for a peer whose identity the caller has actually established. Two dials given the same hop are treated as one endpoint: routes learned from either are kept off both, and content arriving on either is interchangeable with the other’s. That is the point when they really are one peer reconnecting or running redundant links, and a bug otherwise. Derive it from the authenticated identity, never from something coarser like the remote address.
Sourcepub async fn connect_lite<S>(
&self,
now: Instant,
session: S,
) -> Result<(Session, Driver<S>), Error>where
S: Session,
pub async fn connect_lite<S>(
&self,
now: Instant,
session: S,
) -> Result<(Session, Driver<S>), Error>where
S: Session,
Perform the MoQ handshake for moq-lite only, over any transport.
Unlike connect this puts no thread-affinity bound on
the transport, so a pinned !Send transport works and yields a !Send
machine that stays on its thread. The trade is protocol scope: only a
moq-lite ALPN is accepted, since the moq-transport driver still needs a
Boxable transport. An ietf ALPN, an
unknown one, or the legacy no-ALPN SETUP negotiation is refused with
Error::Version.