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+).
Every announcement crossing the connection adds this to its route cost, so
routing prefers cheap paths over short ones. Use 0 for a link that should
look free (a sibling in the same datacenter), and something large for one that
should be a last resort (a metered backbone). An unpriced link costs 1,
which makes the cost track the hop count and so reproduces plain
shortest-path routing.
The dialing side owns the price: it is declared in our SETUP so the server charges the same link the same amount. A server never sets one.
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: every moq-transport version (the protocol carries no hop ids), and moq-lite peers without the hops extension. Broadcasts received from such a peer are normally attributed to a random per-connection origin, so they can’t be recognized across sessions. This knob pins that 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 (moq-lite with the hops extension) wins over this one.