pub struct PairingProtocol { /* private fields */ }Expand description
Transport-agnostic pairing protocol state machine.
EphemeralSecret from x25519-dalek is !Clone + !Serialize, so this
state machine is inherently ephemeral — it lives in memory only and
cannot be persisted across app restarts.
Usage:
ⓘ
// Initiator side:
let (protocol, token) = PairingProtocol::initiate(now, controller_did, endpoint, caps)?;
let token_bytes = serde_json::to_vec(&token)?;
// Send token_bytes to peer over transport (HTTP, BLE, QR, etc.)
// After receiving response bytes from peer:
let completed = protocol.complete(now, response_bytes)?;
// completed.shared_secret, completed.peer_did are now availableImplementations§
Source§impl PairingProtocol
impl PairingProtocol
Sourcepub fn initiate(
now: DateTime<Utc>,
controller_did: String,
endpoint: String,
capabilities: Vec<String>,
) -> Result<(Self, PairingToken), ProtocolError>
pub fn initiate( now: DateTime<Utc>, controller_did: String, endpoint: String, capabilities: Vec<String>, ) -> Result<(Self, PairingToken), ProtocolError>
Initiate a pairing session.
Args:
now- Current time (injected, not fetched internally)controller_did- The initiator’s identity DIDendpoint- Registry endpoint URLcapabilities- Capabilities to grant to the paired device
Usage:
ⓘ
let (protocol, token) = PairingProtocol::initiate(now, did, endpoint, caps)?;Sourcepub fn complete(
self,
now: DateTime<Utc>,
response_bytes: &[u8],
) -> Result<CompletedPairing, ProtocolError>
pub fn complete( self, now: DateTime<Utc>, response_bytes: &[u8], ) -> Result<CompletedPairing, ProtocolError>
Complete the pairing exchange with a received response.
Consumes the protocol state (ephemeral secret is used exactly once).
Args:
now- Current time for expiry checkingresponse_bytes- SerializedPairingResponsefrom the peer
Usage:
ⓘ
let completed = protocol.complete(now, &response_bytes)?;Sourcepub fn complete_with_response(
self,
now: DateTime<Utc>,
response: PairingResponse,
) -> Result<CompletedPairing, ProtocolError>
pub fn complete_with_response( self, now: DateTime<Utc>, response: PairingResponse, ) -> Result<CompletedPairing, ProtocolError>
Complete the pairing exchange with a structured response.
Args:
now- Current time for expiry checkingresponse- The peer’sPairingResponse
Sourcepub fn token(&self) -> &PairingToken
pub fn token(&self) -> &PairingToken
Get a reference to the pairing token for display/transmission.
Auto Trait Implementations§
impl Freeze for PairingProtocol
impl RefUnwindSafe for PairingProtocol
impl Send for PairingProtocol
impl Sync for PairingProtocol
impl Unpin for PairingProtocol
impl UnsafeUnpin for PairingProtocol
impl UnwindSafe for PairingProtocol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more