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_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.
Pass stats::Session::default (a no-op context) to opt out.
Sourcepub fn with_origin(self, origin: Producer) -> Self
pub fn with_origin(self, origin: Producer) -> Self
Set both publish and subscribe from one shared origin::Producer.
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 async fn accept<S: Session>(
&self,
session: S,
) -> Result<(Session, Driver), Error>
pub async fn accept<S: Session>( &self, session: S, ) -> Result<(Session, Driver), Error>
Perform the MoQ handshake as a server, returning the Session and the
Driver that runs its protocol work.
Convenience wrapper over accept_request that
completes the handshake immediately. Use accept_request when you need to
inspect the client’s advertised path before deciding what to serve.
Sourcepub async fn accept_request<S: Session>(
&self,
session: S,
) -> Result<Request<S>, Error>
pub async fn accept_request<S: Session>( &self, session: S, ) -> Result<Request<S>, Error>
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 Request: inspect path, set the origins to
serve, and call ok or close. Session start
is deferred to ok(), so origins set on the Request always take effect.
The path is surfaced for moq-lite-05 and every moq-transport draft we speak; it’s empty on versions with no in-band request path (e.g. lite 01-04).