Skip to main content

PairingDesk

Struct PairingDesk 

Source
pub struct PairingDesk { /* private fields */ }
Expand description

The responder’s side of pairing that involves the operator: the PIN it shows, joiners that wait for a typed PIN or an approval, and the throttles. Clone it to share it between the connections and the app’s own surface.

The desk shows nothing and asks nobody: the caller displays show_pin’s PIN, lists slots, passes what the operator typed to submit_code or find_device, and calls approve or deny.

Implementations§

Source§

impl PairingDesk

Source

pub fn builder() -> PairingDeskBuilder

A builder with nothing set.

Source§

impl PairingDesk

Source

pub fn new(random: Random) -> Self

A desk with the default options and limits, the system clock, and random for PINs, slots and user codes: PairingDesk::builder().random(random).build().

Source

pub fn settings(&self) -> PairingDeskSettings

The settings in force.

Source

pub fn non_defaults(&self) -> Vec<NonDefault>

Every setting that differs from its default, named by key path.

Source

pub fn options(&self) -> PairingOptions

The options in force.

Source

pub fn limits(&self) -> DeskLimits

The limits in force.

Source

pub fn show_pin(&self) -> Result<ShownPin, Error>

Makes a new PIN for joiners to type, replacing the one shown before, and returns it for the caller to display.

§Errors

Error::Random when the random source fails.

Source

pub fn shown_pin(&self) -> Option<ShownPin>

The PIN shown now, while it lasts and has attempts left.

Source

pub fn clear_pin(&self)

Withdraws the shown PIN.

Source

pub fn slots(&self) -> Vec<PendingSlot>

The joiners that show their own PIN and wait for it to be typed, by slot.

Source

pub fn submit_code(&self, code: &PairingCode) -> Result<(), PairingError>

Hands the PIN the operator typed to the joiner waiting in code.slot. Whether it is right is found by the PAKE; the slot is used either way.

§Errors

PairingError::Refused with PairRefusal::WrongCode when no joiner waits in that slot (or slot is None).

Source

pub fn find_device( &self, approver: &str, code: &str, ) -> Result<PendingDevice, PairingError>

The device-flow joiner whose user code the operator entered, for the caller to approve or deny. approver names who entered it (an account, a session), for the per-approver throttle.

The code is matched exactly over the user-code alphabet, in constant time against every pending code.

§Errors

PairingError::Local with Error::InvalidCode when code is not of the alphabet (not counted as a wrong entry); PairRefusal::Throttled when the approver or all approvers entered too many wrong codes recently; PairRefusal::WrongCode when no pending joiner has it (counted).

Source

pub fn approve(&self, device: &PendingDevice) -> Result<(), PairingError>

Approves a device-flow joiner: its responder accepts its key and tells it so.

§Errors

PairRefusal::Expired when it expired, was decided, or disconnected.

Source

pub fn deny(&self, device: &PendingDevice) -> Result<(), PairingError>

Denies a device-flow joiner: its responder refuses it and tells it so.

§Errors

As approve.

Source

pub fn sweep(&self)

Expires the shown PIN and the waiting joiners by the clock, waking their responders. The waits below also do it; call it when the clock is not the system’s.

Source

pub fn wait(&self, ticket: Ticket) -> Decision

Blocks until ticket is decided or expires. Under the system clock it rechecks expiry every second; under another clock, sweep wakes it.

Source

pub fn decided(&self, ticket: Ticket) -> Decided ⓘ

A future of wait’s decision. It is woken by a decision or by sweep; an async caller that relies on expiry sweeps now and then.

Trait Implementations§

Source§

impl Clone for PairingDesk

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 Debug for PairingDesk

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl TryFrom<PairingDeskParts> for PairingDesk

Source§

fn try_from(parts: PairingDeskParts) -> Result<Self, Error>

Source§

type Error = Error

The type returned in the event of a conversion error.

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.