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>;
}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§
Sourcefn pairing_token(&self, node: NodeId, now: Timestamp) -> Option<PairingToken>
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”).
Sourcefn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>
fn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>
Which of our nodes an alias names.
Sourcefn sole_node(&self) -> Option<NodeId>
fn sole_node(&self) -> Option<NodeId>
Our node, when the endpoint hosts exactly one and the client named none.
Sourcefn node(&self, node: NodeId) -> Option<NodeDescription>
fn node(&self, node: NodeId) -> Option<NodeDescription>
Everything about one of our nodes.
Sourcefn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>
fn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>
Every node this endpoint hosts, for GET /v1/nodes.
Sourcefn pair(&self, paired: PairedNode)
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.
Sourcefn paired(&self, key: PairingKey) -> Option<PairedNode>
fn paired(&self, key: PairingKey) -> Option<PairedNode>
One pairing.
Sourcefn pairings_of(&self, local: NodeId) -> Vec<PairingKey>
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.
Sourcefn set_tokens(&self, key: PairingKey, tokens: TokenStore)
fn set_tokens(&self, key: PairingKey, tokens: TokenStore)
Replace a pairing’s tokens after a rotation.
Sourcefn revoke(&self, key: PairingKey)
fn revoke(&self, key: PairingKey)
Mark a pairing unpaired by this endpoint, keeping it until the peer has been told.
Sourcefn unpair(&self, key: PairingKey)
fn unpair(&self, key: PairingKey)
Forget a pairing.
Sourcefn pairing_for_token(&self, token: &AccessToken) -> Option<PairingKey>
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".