Skip to main content

Server

Struct Server 

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

A MoQ server session builder.

Implementations§

Source§

impl Server

Source

pub fn new() -> Self

A server that neither publishes nor subscribes until configured.

Source

pub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self

Publish to the connected client: the session reads from the given origin (pass an origin::Producer or origin::Consumer by reference) and forwards its announcements. Omit to publish nothing. Pre-scoped via origin::Producer::scope for token-gated relays.

Source

pub fn with_subscriber(self, subscribe: Producer) -> Self

Subscribe to the connected client: the session writes the broadcasts the client announces into this origin::Producer. Omit to subscribe to nothing.

Source

pub fn with_allocator(self, allocator: Allocator) -> Self

Share allocator’s reservations with every session this server accepts.

The accepting mirror of Client::with_allocator: each session probes for what the reservations add up to, and its Session::allocator reserves into the same registry. Without one, each session starts an empty registry of its own.

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 each client can make its session hold. Defaults to session::Limits::default.

Source

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

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

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_timeout(self, timeout: Option<Duration>) -> Self

Bound each accept, from the connection’s arrival through SETUP, the caller’s admission, and, on moq-lite 01/02, the server SETUP reply. Other versions send their SETUP from the started session’s driver, outside this bound. A connection that overruns it is closed with Error::Timeout’s code. None waits forever. Defaults to DEFAULT_TIMEOUT.

Source

pub fn deadline(&self, arrived: Instant) -> Option<Instant>

When a connection that arrived at arrived must be accepted by, or None to wait forever, including past the clock’s range.

A caller that runs a transport handshake before handshake bounds that handshake by this instant, then hands it to Accept::with_deadline.

Source

pub fn with_receive_window(self, window: NonZeroU64) -> Self

Open the connection’s receive window to window once the caller admits the session, before SETUP is answered, so a transport can hold most of it back until then.

A transport that cannot change its window keeps its own. Unset, the window stays as the transport set it.

Source

pub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self

Probe a quiet client and report it Stale through Session::liveness before closing on it; see KeepAlive.

Started once the caller admits the session (Handshake::ok), which refuses the session with Error::KeepAlive on a transport that cannot run it. A Handshake can set its own with Handshake::with_keep_alive.

Source

pub fn with_cost(self, cost: impl Into<Cost>) -> Self

Price every session this server accepts, as Client::with_cost prices a dialed link: added to the route cost of every announcement the client sends, and declared in our SETUP so the client adds it to every announcement we send.

A price set here wins over the one the client declares. Without one, the client’s price applies, then 1. Zero is refused on moq-lite-07. Price one session after authorizing it with Handshake::with_cost.

Source

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

Perform the MoQ handshake as a server, returning the Session and its Driver.

Poll the returned driver with nondecreasing time, starting at now. The accept deadline counts from now too.

Convenience wrapper over handshake that completes the handshake immediately. Use handshake when you need to inspect the client’s advertised path before deciding what to serve.

Source

pub fn handshake(&self, now: Instant, session: impl Boxable) -> Accept ⓘ

Begin the MoQ handshake, pausing once the client’s request path is known so the caller can authorize/scope before serving.

Reads the client’s SETUP (the in-band path lives there on URL-less transports), then returns a Handshake: inspect path, set the origins to serve, and call ok or close. Session start is deferred to ok(), so origins set on the handshake always take effect.

The path is surfaced for moq-lite-05 and newer, and every moq-transport draft we speak; it’s empty on versions with no in-band request path (lite 01-04).

A SETUP that fails to parse or negotiate closes the session with the matching code, so the peer learns why instead of seeing a bare disconnect.

The session’s clock starts at now, and so does the accept deadline (with_timeout) unless Accept::with_deadline moves it. The deadline goes on to bound the caller’s admission (Handshake::expired) and the SETUP reply (Handshake::ok).

Trait Implementations§

Source§

impl Clone for Server

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 Server

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