Skip to main content

Handle

Struct Handle 

Source
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

Source

pub fn new() -> Self

A handle backing no session yet, for Client::with_auth.

Source

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.

Source

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.

Source

pub fn authorize(&self, grant: &Grant)

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.

Source

pub fn abort(&self, err: Error)

End the handle with err: every token ends, its sessions stop presenting them, and the peer’s queued tokens are refused. A handle a session created for itself ends with that session.

Trait Implementations§

Source§

impl Clone for Handle

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 Handle

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