Skip to main content

PairingResponder

Struct PairingResponder 

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

The responder’s side of a pairing exchange: it redeems invitations from its PairingStore (a TrustStore, or a host’s own), takes PINs and decisions from its PairingDesk, and accepts the joiner’s key in the store when the pairing succeeds.

Implementations§

Source§

impl PairingResponder

Source

pub fn new<S: PairingStore + Clone + 'static>( channel: Channel, store: &S, desk: &PairingDesk, source: Option<SocketAddr>, ) -> Self

A responder over channel, for a joiner that connected from source (used by the desk’s per-source throttle). store is a TrustStore or a host’s own PairingStore; the responder keeps a clone.

Source

pub fn with_store( channel: Channel, store: Arc<dyn PairingStore>, desk: &PairingDesk, source: Option<SocketAddr>, ) -> Self

As new, over a store that is already shared, or that cannot be cloned.

Source

pub fn transmit(&mut self) -> Option<Vec<u8>>

The next message to send, or None. Call until None.

Source

pub fn awaiting(&self) -> Option<Ticket>

The decision this responder waits for, when it waits: hand it to PairingDesk::wait or PairingDesk::decided, then to resume.

Source

pub fn joiner(&self) -> Option<&KeyMaterial>

The joiner’s key, once its first message arrived.

Source

pub fn is_complete(&self) -> bool

Whether the exchange succeeded.

Source

pub fn finish(self) -> Result<Paired, PairingError>

The paired joiner, already accepted in the store.

§Errors

PairingError::Protocol before completion.

Source

pub fn receive(&mut self, message: &[u8]) -> Result<(), PairingError>

Takes one message from the joiner.

§Errors

PairingError::Refused when this side refuses (a refusal is then queued for the joiner) or the joiner did; PairingError::Protocol; PairingError::Local when the store or the random source fails. The exchange is over after an error.

Source

pub fn resume(&mut self, decision: Decision) -> Result<(), PairingError>

Settles the decision awaiting named.

§Errors

As receive; PairRefusal::Denied or PairRefusal::Expired when that is the decision.

Source

pub fn deadline(&self) -> Option<SystemTime>

When this exchange must be over, on the desk’s clock: from the joiner’s first message, PairingOptions::pin_ttl for a PIN and PairingOptions::device_ttl for the device flow. None before that message, and for an invitation, which ends with it. A transport reads with a timeout up to it, then calls check_deadline.

Source

pub fn time_left(&self) -> Option<Duration>

How long until the deadline, on the desk’s clock: zero once it passed, None while there is none. A transport’s read timeout.

Source

pub fn check_deadline(&mut self) -> Result<(), PairingError>

Ends the exchange once its deadline passed: the joiner is told Expired, and the slot or user code is released. receive and resume check it first.

§Errors

PairRefusal::Expired when the deadline passed.

Trait Implementations§

Source§

impl Debug for PairingResponder

Source§

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

Formats the value using the given formatter. 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> 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, 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.