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 the SETUP (moq-lite-05 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).
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_origin(self, origin: Origin) -> Self
pub fn with_peer_origin(self, origin: Origin) -> Self
Assign an origin (hop) id to the peer, used whenever the peer doesn’t declare one itself.
Some relays never declare their identity: moq-lite peers without the hops
extension, and moq-transport peers that don’t negotiate the MoQ Cluster
extension (or predate it, on moqt-16 and earlier).
Broadcasts received from such a peer are normally attributed to the reserved
origin 0 (“unknown”), which identifies nothing: it never proves continuity,
so their advertisements neither splice nor survive a restart in place. This
knob pins a real identity instead, exactly as if the peer had declared it:
- broadcasts received from the peer carry
originin their hop chains, so every session dialing the same relay (with the same id) resolves to one route and loop checks can recognize it; - broadcasts whose hop chain already contains
originare neither announced nor served back to the peer, preventing an echo through a relay that does no loop detection of its own.
An identity the peer does declare wins over this one.