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,
and how the session ended is recorded there.
Pass stats::Session::default (a no-op context) to opt out.
Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
Cap what the server can make this session hold. Defaults to session::Limits::default.
Sourcepub fn with_allocator(self, allocator: Allocator) -> Self
pub fn with_allocator(self, allocator: Allocator) -> Self
Share allocator’s reservations with every session this client dials.
Each session probes for what they add up to, and its
Session::allocator reserves into the same registry,
so a reservation taken on one session still counts after a reconnect. Without
one, each session starts an empty registry of its own.
Sourcepub fn with_viewers(self, viewers: Viewers) -> Self
pub fn with_viewers(self, viewers: Viewers) -> Self
Share viewers with every session this client dials.
Each session sends what they add up to as its PROBE target, and its
Session::viewers watches into the same registry, so
a viewer taken on one session still counts after a reconnect. Without one, each
session starts an empty registry of its own.
Sourcepub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self
pub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self
Probe a quiet peer and report it Stale through
Session::liveness before closing on it; see KeepAlive.
Each session’s connect fails with Error::KeepAlive on a transport that refuses it.
Without one, a session keeps the transport’s own keep-alive and never reports staleness.
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_url(self, url: Url) -> Self
pub fn with_url(self, url: Url) -> Self
Name the URL each session is dialed at, so the server learns the request target.
A transport whose request URI already reaches the server
(Address::Uri) sends nothing more. Otherwise
SETUP carries the path and query (moq-lite-05 and newer, every moq-transport
draft), which is how a credential in the query (?jwt=) arrives, and for
moqt:// the authority (moq-transport only). A unix:// URL names its target in
its ?path= query, since its path is the socket file.
Sourcepub fn with_token(self, token: Token) -> Self
pub fn with_token(self, token: Token) -> Self
Present token as the connection credential in SETUP, on versions that carry one
(moq-lite-07+ and every moq-transport draft we speak). The session’s empty-token
AUTH stream then answers with its grant.
Other versions send nothing, so a caller that may negotiate one also puts the
token in the URL query. moq-lite carries no Token Type, so only
Token::OUT_OF_BAND reaches it; another type fails
the handshake.
Sourcepub fn with_auth(self, auth: Handle) -> Self
pub fn with_auth(self, auth: Handle) -> Self
Build every session on auth, so each presents the tokens it holds and a route
naming one of its Credentials keeps it across a reconnect. Omit to
give each session a handle of its own, which ends with it.
The handle backs one active session at a time, plus the ones draining after a
GOAWAY: connecting another while one is still active fails with
Error::Duplicate.
Sourcepub fn with_ietf(self, ietf: bool) -> Self
pub fn with_ietf(self, ietf: bool) -> Self
Offer the ietf extension on moq-lite-07, so a hop between relays carries the
moq-transport state of a track a moq-transport publisher made. Off by default.
Behind the relay feature: moq-relay’s door for its own links, not an API.
Sourcepub fn with_solicit(self, solicit: bool) -> Self
pub fn with_solicit(self, solicit: bool) -> Self
Whether to offer MoQ Solicit on moq-transport, which every session does. Off acts as a moq-transport peer without it.
Behind the test-support feature: a test’s door, not an API.
Sourcepub fn with_implementation(self, implementation: impl Into<String>) -> Self
pub fn with_implementation(self, implementation: impl Into<String>) -> Self
Set the implementation to advertise in SETUP, as space-separated name/version
product tokens, outermost first. Defaults to IMPLEMENTATION;
an empty string advertises nothing.
Sourcepub fn with_cost(self, cost: impl Into<Cost>) -> Self
pub fn with_cost(self, cost: impl Into<Cost>) -> Self
Price this link, in the units the rest of the mesh uses (moq-lite-06+, and moq-transport via the MoQ Cluster extension).
The dialer is the side that knows what a link costs, because it chose the peer:
use 1 for a sibling in the same datacenter and something large for another
region across a metered backbone. Zero is refused on moq-lite-07, whose routing
needs every link to cost something. 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_node(self, node: NonZeroU64) -> Self
pub fn with_peer_node(self, node: NonZeroU64) -> Self
Assign the Node ID this peer’s routes are attributed to, overriding the fresh per-dial default.
A dialed session whose peer declares no Node ID 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 node 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.