pub struct Memory { /* private fields */ }Available on crate feature
connect-server only.Expand description
A Store that keeps everything in memory.
Correct, and suitable for a test or a device that re-pairs on every boot. Anything that must survive a power cut needs a real one.
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn add_node(&self, node: NodeDescription, alias: Option<NodeIdAlias>)
pub fn add_node(&self, node: NodeDescription, alias: Option<NodeIdAlias>)
Add one of our own nodes.
Sourcepub fn open_for_pairing(&self, node: NodeId, token: PairingToken)
pub fn open_for_pairing(&self, node: NodeId, token: PairingToken)
Open one of our nodes for pairing with a static token — the one printed on the
device, valid until close_pairing or a completed pairing.
Sourcepub fn open_for_pairing_until(
&self,
node: NodeId,
token: PairingToken,
expires: Timestamp,
)
pub fn open_for_pairing_until( &self, node: NodeId, token: PairingToken, expires: Timestamp, )
Open one of our nodes for pairing with a dynamic token, valid for
DYNAMIC_TOKEN_LIFETIME from now — what pressing the button on a device with
a display does.
Sourcepub fn open_for_pairing_dynamic(
&self,
node: NodeId,
token: PairingToken,
now: Timestamp,
)
pub fn open_for_pairing_dynamic( &self, node: NodeId, token: PairingToken, now: Timestamp, )
open_for_pairing_until now plus the
recommended five minutes.
Sourcepub fn close_pairing(&self, node: NodeId)
pub fn close_pairing(&self, node: NodeId)
Stop accepting pairings for a node.
Trait Implementations§
Source§impl Store for Memory
impl Store for Memory
Source§fn 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. Read more
Source§fn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>
fn resolve_alias(&self, alias: &NodeIdAlias) -> Option<NodeId>
Which of our nodes an alias names.
Source§fn sole_node(&self) -> Option<NodeId>
fn sole_node(&self) -> Option<NodeId>
Our node, when the endpoint hosts exactly one and the client named none.
Source§fn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>
fn nodes(&self) -> Vec<(NodeDescription, Option<NodeIdAlias>)>
Every node this endpoint hosts, for
GET /v1/nodes.Source§fn 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.
Source§fn paired(&self, key: PairingKey) -> Option<PairedNode>
fn paired(&self, key: PairingKey) -> Option<PairedNode>
One pairing.
Source§fn 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. Read more
Source§fn set_tokens(&self, key: PairingKey, tokens: TokenStore)
fn set_tokens(&self, key: PairingKey, tokens: TokenStore)
Replace a pairing’s tokens after a rotation.
Source§fn revoke(&self, key: PairingKey)
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)
fn unpair(&self, key: PairingKey)
Forget a pairing.
Source§fn 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.
Auto Trait Implementations§
impl !Freeze for Memory
impl Forget for Memory
impl Move for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
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