pub struct Client { /* private fields */ }Expand description
Client for establishing MoQ connections over QUIC, WebTransport, or WebSocket.
Create via ClientConfig::init or Client::new.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(config: ClientConfig) -> Result<Self>
pub fn new(config: ClientConfig) -> Result<Self>
Build a client from its config, binding the QUIC socket up front.
Sourcepub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
pub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
Publish the given origin to every session this client opens.
Sourcepub fn with_subscriber(self, subscribe: Producer) -> Self
pub fn with_subscriber(self, subscribe: Producer) -> Self
Subscribe to the peer’s broadcasts, ingesting them into the given origin.
Sourcepub fn with_stats(self, stats: Session) -> Self
pub fn with_stats(self, stats: Session) -> Self
Attach a per-connection moq_net::stats::Session context to all sessions
opened by this client.
Sourcepub fn with_cost(self, cost: u64) -> Self
pub fn with_cost(self, cost: u64) -> Self
Price the links this client dials; see moq_net::Client::with_cost.
Sourcepub fn reconnect(&self, url: Url) -> Reconnect
pub fn reconnect(&self, url: Url) -> Reconnect
Start a background reconnect loop that connects to the given URL, waits for the session to close, then reconnects with exponential backoff.
Returns a Reconnect handle; drop the last handle to stop the loop.
Sourcepub fn publish(self, origin: Consumer) -> Option<Reconnect>
pub fn publish(self, origin: Consumer) -> Option<Reconnect>
Dial the configured ClientConfig::connect URL, publishing origin to it
and reconnecting with backoff until the returned handle is dropped.
Returns None when no --client-connect URL was configured, so a caller
that may run server-only doesn’t have to branch on the URL itself.
Sourcepub fn consume(self, origin: Producer) -> Option<Reconnect>
pub fn consume(self, origin: Producer) -> Option<Reconnect>
Dial the configured ClientConfig::connect URL, consuming its broadcasts
into origin and reconnecting with backoff until the returned handle is
dropped.
Broadcasts fed by these sessions linger across a session drop for as long
as the reconnect loop keeps retrying (Backoff::linger): a relay restart
is a bounded gap the reconnect splices over, not a teardown. When the loop
gives up, its error surfaces (via Reconnect::closed) just before the
broadcasts abort.
Returns None when no --client-connect URL was configured.
Sourcepub async fn connect(&self, url: Url) -> Result<Session>
pub async fn connect(&self, url: Url) -> Result<Session>
Dial the given URL and complete the MoQ handshake.
The scheme picks the transport, and https:// races QUIC against the
WebSocket fallback so a blocked UDP path still connects. The session’s
protocol driver is spawned on the current tokio runtime; the session
closes once the last returned handle drops.