Skip to main content

Store

Trait Store 

Source
pub trait Store:
    Send
    + Sync
    + 'static {
    // Required methods
    fn pairing_token(
        &self,
        node: NodeId,
        now: Timestamp,
    ) -> Option<PairingToken>;
    fn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>;
    fn sole_node(&self) -> Option<NodeId>;
    fn node(&self, node: NodeId) -> Option<NodeDescription>;
    fn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>;
    fn pair(&self, paired: PairedNode);
    fn paired(&self, key: PairingKey) -> Option<PairedNode>;
    fn pairings_of(&self, local: NodeId) -> Vec<PairingKey>;
    fn set_tokens(&self, key: PairingKey, tokens: TokenStore);
    fn revoke(&self, key: PairingKey);
    fn unpair(&self, key: PairingKey);
    fn pairing_for_token(&self, token: &AccessToken) -> Option<PairingKey>;
}
Available on crate feature connect-server only.
Expand description

Everything an endpoint must remember across a restart.

Pairings that live only in memory are pairings a power cut destroys, and the recovery from that is a person walking to the device with a pairing code. Implement this over whatever the host actually persists to.

Required Methods§

Source

fn pairing_token(&self, node: NodeId, now: Timestamp) -> Option<PairingToken>

The pairing token currently accepting a pairing for one of our nodes, if any.

None means NoValidPairingTokenOnPairingServer: the node exists but is not accepting pairings — the normal state of a device nobody has just pressed the button on, and the state a dynamic token returns to when it expires (S2C §pairing token: “Dynamically generated pairing tokens must expire”).

Source

fn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>

Which of our nodes an alias names.

Source

fn sole_node(&self) -> Option<NodeId>

Our node, when the endpoint hosts exactly one and the client named none.

Source

fn node(&self, node: NodeId) -> Option<NodeDescription>

Everything about one of our nodes.

Source

fn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>

Every node this endpoint hosts, for GET /v1/nodes.

Source

fn pair(&self, paired: PairedNode)

Record a completed pairing, replacing any earlier one under the same key, and consume the pairing token that opened it.

Source

fn paired(&self, key: PairingKey) -> Option<PairedNode>

One pairing.

Source

fn pairings_of(&self, local: NodeId) -> Vec<PairingKey>

Every pairing one of our own nodes has, revoked ones excluded.

S2C §Pairing process: “A RM can only be paired with one CEM at a time.” Applying that needs this question answered.

Source

fn set_tokens(&self, key: PairingKey, tokens: TokenStore)

Replace a pairing’s tokens after a rotation.

Source

fn revoke(&self, key: PairingKey)

Mark a pairing unpaired by this endpoint, keeping it until the peer has been told.

Source

fn unpair(&self, key: PairingKey)

Forget a pairing.

Source

fn pairing_for_token(&self, token: &AccessToken) -> Option<PairingKey>

Which pairing a presented access token belongs to, revoked pairings excluded.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§