Skip to main content

PairingStore

Trait PairingStore 

Source
pub trait PairingStore: Send + Sync {
    // Required methods
    fn accept_key(&self, key: &KeyMaterial) -> Result<PeerId, Error>;
    fn redeem(&self, secret: &[u8; 32]) -> Result<Invitation, Error>;
    fn accepted_key(&self, id: &PeerId) -> Option<KeyMaterial>;
}
Expand description

What a PairingResponder needs of the storage that holds the keys it admits and the invitations it redeems.

TrustStore is the directory implementation. A host that keeps enrollment in its own durable storage implements this, so the admission and the redeemed invitation commit together with its other records.

Required Methods§

Source

fn accept_key(&self, key: &KeyMaterial) -> Result<PeerId, Error>

Accepts key and returns its id.

§Errors

Error::AlreadyAccepted when it is accepted and current, which the responder takes as success; Error::Material when the key is not valid; Error::Io or another error when it cannot be written.

Source

fn redeem(&self, secret: &[u8; 32]) -> Result<Invitation, Error>

Uses up one redemption of the open invitation whose secret this is, atomically: of concurrent redemptions of a single-use invitation exactly one succeeds.

§Errors

Error::NotInvited when no open invitation has this secret, Error::Expired when it expired, and a storage error.

Source

fn accepted_key(&self, id: &PeerId) -> Option<KeyMaterial>

The key of an accepted, current peer, or None. The responder asks after accept_key and refuses to report a pairing the store does not hold.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<S: PairingStore + ?Sized> PairingStore for Arc<S>

Implementors§