pub struct Handshake { /* private fields */ }Expand description
A paused server-side handshake.
Returned by Server::handshake once the peer’s advertised
path is known but before the session is granted anything. Set
the origins to serve, then call ok to complete the handshake, or
close to reject it. Modeled on the WebTransport Request in
moq-tokio.
Implementations§
Source§impl Handshake
impl Handshake
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
The request path the client advertised in its SETUP.
Empty when the client advertised none: either it sent an empty path, or the
version carries none in-band (lite 01-04). Those mean the same thing, so the
wire distinction isn’t surfaced. Populated for moq-lite-05 and newer,
and every moq-transport draft we speak. See the note on Server::handshake.
Sourcepub fn role(&self) -> Option<Role>
pub fn role(&self) -> Option<Role>
The single Role the client advertised in its SETUP, or None for a
bidirectional session.
Only moq-lite-05 and newer carry a role, so None covers three cases
that the wire doesn’t distinguish: an older version, a client that omitted the parameter, and a
client that explicitly advertised both directions. All three mean the same thing
(the client may publish and subscribe), so authorize on what the token grants.
See the note on Server::handshake.
Sourcepub fn peer_node(&self) -> Option<NonZeroU64>
pub fn peer_node(&self) -> Option<NonZeroU64>
The identity the peer declared for itself, when the negotiated protocol carries one.
A moq-lite-05+ endpoint declares this when it attaches a publish or subscribe
origin: its Hop ID, or from moq-lite-07 its Node ID. A moq-transport endpoint
declares its Hop ID via the MoQ Cluster extension. Older versions and endpoints
without one return None. origin::Producer::is_own tells whether it is ours.
Self-declared, so treat it as a correlation hint rather than an authenticated identity: authorize on the token or client certificate.
Sourcepub fn peer_implementation(&self) -> Option<&str>
pub fn peer_implementation(&self) -> Option<&str>
The implementation the client advertised in its SETUP, such as moq-net-rs/0.3.10.
None when it advertised none or its version carries no SETUP (moq-lite 01-04),
which in practice means it predates the parameter. Peer-controlled: use it for
logs and rollout counts, never to authorize.
Sourcepub fn auth(&self) -> Handle
pub fn auth(&self) -> Handle
The session’s auth handle, the same one Session::auth returns once accepted.
Sourcepub fn requests(&mut self) -> Requests
pub fn requests(&mut self) -> Requests
Answer every token the client presents yourself, instead of the default acceptor:
on its own AUTH stream, or riding one of its moq-transport SUBSCRIBE or
PUBLISH_NAMESPACE requests as an AUTHORIZATION TOKEN.
Without it the session grants the client what its own origin handles allow for the
connection’s credential, and refuses any other token as unsupported, along with the
request that carried it. A later call hands the queue to the new auth::Requests,
ending the earlier one.
The client’s credit bounds how many tokens wait unanswered: each AUTH token holds its stream open, and each request token holds its request’s slot, until it is answered or withdrawn. A withdrawn token leaves the queue.
Sourcepub fn token(&self) -> Option<&Token>
pub fn token(&self) -> Option<&Token>
The connection credential the client presented in its SETUP: moq-transport’s
AUTHORIZATION TOKEN option, or moq-lite-07’s Token parameter.
Older moq-lite versions carry none, so they return None. The transport has not
verified it: authorize on it the way you would a URL token.
Sourcepub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
pub fn with_publisher(self, publish: impl Consume<Consumer>) -> Self
Sourcepub fn with_subscriber(self, subscribe: Producer) -> Self
pub fn with_subscriber(self, subscribe: Producer) -> Self
Subscribe to the connected client. Overrides any value from the Server builder.
Sourcepub fn with_peer_node(self, node: NonZeroU64) -> Self
pub fn with_peer_node(self, node: NonZeroU64) -> Self
Assign the hop id this peer’s routes are attributed to, overriding the fresh per-session default.
Only for a peer whose identity the server has actually established, such as one
authenticated by mTLS or a token (crate::Client::with_peer_node is the
dialing-side equivalent). An identity the peer declares on the wire still wins.
Two sessions given the same origin 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.
Sourcepub fn with_stats(self, stats: Session) -> Self
pub fn with_stats(self, stats: Session) -> Self
Set the per-connection stats::Session context. Overrides any value from the
Server builder.
Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
Set the session’s limits after authorizing the peer and before answering SETUP.
Sourcepub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self
pub fn with_keep_alive(self, keep_alive: KeepAlive) -> Self
Run keep_alive on this session. Overrides any value from the Server builder; see
Server::with_keep_alive.
Sourcepub fn with_cost(self, cost: impl Into<Cost>) -> Self
pub fn with_cost(self, cost: impl Into<Cost>) -> Self
Price this session’s link; see Server::with_cost. Overrides any value from the
Server builder, so a server can price a peer once it knows who it is.
Sourcepub fn with_receive_window(self, window: NonZeroU64) -> Self
pub fn with_receive_window(self, window: NonZeroU64) -> Self
Open the receive window to window on ok. Overrides any value from the
Server builder; see Server::with_receive_window.
Sourcepub fn poll_expired(&mut self, waiter: &Waiter) -> Poll<()>
pub fn poll_expired(&mut self, waiter: &Waiter) -> Poll<()>
Resolve once the accept deadline passes, having refused the session with
Error::Timeout; never, without a deadline.
Race the admission decision against it, so a peer cannot hold the connection open
behind a decision that never comes. Once it resolves, ok fails with the
timeout.
Sourcepub async fn expired(&mut self)
pub async fn expired(&mut self)
Resolve once the accept deadline passes, having refused the session with
Error::Timeout; never, without a deadline.
Race the admission decision against it, so a peer cannot hold the connection open
behind a decision that never comes. Once it resolves, ok fails with the
timeout.
Awaits poll_expired.
Sourcepub async fn ok(self) -> Result<(Session, Driver), Error>
pub async fn ok(self) -> Result<(Session, Driver), Error>
Accept the session, returning the Session and its Driver.
Opens the receive window first (with_receive_window).
Fails with Error::Timeout once the accept deadline passes, whether admission or a
moq-lite 01/02 peer that never takes the SETUP reply ran it out. Dropping a pending ok refuses the
session the same way, so a caller’s own deadline counts too.
Poll or spawn the returned driver to run the session.