Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }
Expand description

A MoQ client session builder.

Implementations§

Source§

impl Client

Source

pub fn new() -> Self

A client that neither publishes nor subscribes until configured.

Source

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.

Source

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.

Source

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.

Source

pub fn with_limits(self, limits: Limits) -> Self

Cap what the server can make this session hold. Defaults to session::Limits::default.

Source

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.

Source

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.

Source

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.

Source

pub fn with_versions(self, versions: Versions) -> Self

Restrict which protocol versions to offer, in preference order. Defaults to every version this crate supports.

Source

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.

Source

pub fn url(&self) -> Option<&Url>

The URL with_url set, if any.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn connect( &self, now: Instant, session: impl Boxable, ) -> impl Future<Output = Result<(Session, Driver), Error>>

Perform the MoQ handshake, returning the Session and its Driver.

Poll the returned driver with nondecreasing time, starting at now.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Client

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more