pub struct Handle { /* private fields */ }Expand description
The tokens this side presents and the grant they earn, across every session built on it.
A session made without one creates its own, returned by Session::auth, which ends
with that session. Pass one to Client::with_auth instead and it outlives its
sessions: each presents every token the handle holds, so a Credential it issued keeps
riding a route’s announcements across a reconnect. It backs one active session at a
time, plus the ones draining after a GOAWAY.
Cheap to clone; every clone shares the same tokens.
Implementations§
Source§impl Handle
impl Handle
Sourcepub fn grant(&self) -> Watch
pub fn grant(&self) -> Watch
The union of every grant this side holds on the live session: None until its peer
first answers a token (with a grant or a refusal), while no session is live, and
forever on a version without AUTH.
Sourcepub fn add(&self, token: impl Into<Bytes>) -> Result<Credential>
pub fn add(&self, token: impl Into<Bytes>) -> Result<Credential>
Present another token on every session of this handle, returning it at once.
The grant joins the union while any clone of the returned Credential lives;
dropping the last withdraws it, answered or not. With no session live it waits for the
next one. Credential::answered resolves on the first verdict. A refusal that may
pass, such as an unreachable auth server, is presented again after a backoff, and so is
a token whose stream the peer drops without a verdict.
§Errors
The handle’s end, or Error::GoingAway when its one session is draining.
Authorize the peer’s connection credential for grant on every session of this
handle, in the session’s own paths. Calling it again re-authorizes, narrower or
wider, replacing the last grant. The session’s origin handles still bound it, so it
never grants more than they allow.
The session’s scope for the peer is this grant and every grant issued to one of its
AUTH tokens through server::Handshake::requests; a session never authorized is bound
only by its origin handles. A request that carries its own token is decided by that
token instead, inside the scope or not.
A narrower scope ends what falls outside at once, with Error::Unauthorized
where it has a reader: announcements to the peer retract, its new requests are
refused, its subscriptions reset, and the broadcasts it published abort. A wider
one brings back what the old scope held back: announcements to the peer are made
again, and so are the peer’s announcements it withheld from the origin, and new
requests are accepted. The rest of the session carries on. It works on every
version, since the session enforces it without the peer’s help.
When the session answers the peer’s connection credential itself, the peer is
told the grant, within what the origin handles allow, expires included. An
application answering tokens through server::Handshake::requests updates its own
Issued grants.