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
impl PairingResponder
Sourcepub fn new<S: PairingStore + Clone + 'static>(
channel: Channel,
store: &S,
desk: &PairingDesk,
source: Option<SocketAddr>,
) -> Self
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.
Sourcepub fn with_store(
channel: Channel,
store: Arc<dyn PairingStore>,
desk: &PairingDesk,
source: Option<SocketAddr>,
) -> Self
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.
Sourcepub fn transmit(&mut self) -> Option<Vec<u8>>
pub fn transmit(&mut self) -> Option<Vec<u8>>
The next message to send, or None. Call until None.
Sourcepub fn awaiting(&self) -> Option<Ticket>
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.
Sourcepub fn joiner(&self) -> Option<&KeyMaterial>
pub fn joiner(&self) -> Option<&KeyMaterial>
The joiner’s key, once its first message arrived.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the exchange succeeded.
Sourcepub fn finish(self) -> Result<Paired, PairingError>
pub fn finish(self) -> Result<Paired, PairingError>
Sourcepub fn receive(&mut self, message: &[u8]) -> Result<(), PairingError>
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.
Sourcepub fn resume(&mut self, decision: Decision) -> Result<(), PairingError>
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.
Sourcepub fn deadline(&self) -> Option<SystemTime>
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.
Sourcepub fn time_left(&self) -> Option<Duration>
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.
Sourcepub fn check_deadline(&mut self) -> Result<(), PairingError>
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.