pub struct Server { /* private fields */ }Expand description
A MoQ server session builder.
Implementations§
Source§impl Server
impl Server
Sourcepub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
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.
Sourcepub fn with_subscriber(self, subscribe: Producer) -> Self
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.
Sourcepub fn with_allocator(self, allocator: Allocator) -> Self
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.
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 each client can make its session hold. Defaults to session::Limits::default.
Sourcepub fn with_versions(self, versions: Versions) -> Self
pub fn with_versions(self, versions: Versions) -> Self
Restrict which protocol versions to accept, in preference order. Defaults to every version this crate supports.
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_timeout(self, timeout: Option<Duration>) -> Self
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.
Sourcepub fn deadline(&self, arrived: Instant) -> Option<Instant>
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.
Sourcepub fn with_receive_window(self, window: NonZeroU64) -> Self
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.
Sourcepub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self
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.
Sourcepub fn with_cost(self, cost: impl Into<Cost>) -> Self
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.
Sourcepub fn accept(
&self,
now: Instant,
session: impl Boxable,
) -> impl Future<Output = Result<(Session, Driver), Error>>
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.
Sourcepub fn handshake(&self, now: Instant, session: impl Boxable) -> Accept ⓘ
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).