Skip to main content

DeviceStore

Trait DeviceStore 

Source
pub trait DeviceStore: Send + Sync {
Show 14 methods // Required methods fn put_code<'life0, 'async_trait>( &'life0 self, code: PairingCode, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn take_code<'life0, 'life1, 'async_trait>( &'life0 self, code_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PairingCode>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn prune_codes<'life0, 'async_trait>( &'life0 self, before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn clear_codes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn put_device<'life0, 'async_trait>( &'life0 self, device: DeviceRecord, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_device<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DeviceRecord>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_devices<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceRecord>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn count_claim_attempt<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn reset_claim_attempts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn put_attachment<'life0, 'async_trait>( &'life0 self, attachment: DeviceAttachment, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn put_attachment_if_absent<'life0, 'async_trait>( &'life0 self, attachment: DeviceAttachment, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn attachments<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, kind: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceAttachment>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn remove_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, kind: &'life2 str, key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait { ... } fn remove_attachments<'life0, 'life1, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Where paired devices and waiting pairing codes are kept (spec 3.3 §10 K2, S-I7), on the backends the kernel’s other stores use, with one conformance suite (device_store_conformance_tests!, feature conformance).

Neither a code nor a token is ever stored: codes by their hash, devices by their token’s hash.

Required Methods§

Source

fn put_code<'life0, 'async_trait>( &'life0 self, code: PairingCode, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Keeps a waiting code, replacing one with the same hash.

Source

fn take_code<'life0, 'life1, 'async_trait>( &'life0 self, code_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PairingCode>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes and returns the code hashed code_hash, expired or not; None when no code has it. Two claims of one code take it once.

Source

fn prune_codes<'life0, 'async_trait>( &'life0 self, before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes the codes that expired at or before before; returns how many.

Source

fn clear_codes<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes every waiting code; returns how many.

Source

fn put_device<'life0, 'async_trait>( &'life0 self, device: DeviceRecord, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Keeps a device, replacing the one with the same id.

Source

fn get_device<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<DeviceRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The device id, revoked and expired ones included.

Source

fn list_devices<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Every device, oldest pairing first, then by id.

Source

fn count_claim_attempt<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Counts one claim attempt and returns how many were counted since the last reset. Every replica over the store shares the count, and concurrent attempts each get a distinct count.

Source

fn reset_claim_attempts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Starts the count of claim attempts again.

Provided Methods§

Source

fn put_attachment<'life0, 'async_trait>( &'life0 self, attachment: DeviceAttachment, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Keeps attachment, replacing the one with its holder, kind and key (spec 3.3 §5.4).

The default refuses: a backend that keeps no attachments says so.

Source

fn put_attachment_if_absent<'life0, 'async_trait>( &'life0 self, attachment: DeviceAttachment, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Keeps attachment unless one with its holder, kind and key exists; whether it wrote. Of concurrent puts of one attachment, from any replica, exactly one writes.

Source

fn attachments<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, kind: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<DeviceAttachment>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

holder’s attachments of kind, by key.

Source

fn remove_attachment<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, kind: &'life2 str, key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Removes holder’s attachment of kind under key; whether there was one.

Source

fn remove_attachments<'life0, 'life1, 'async_trait>( &'life0 self, holder: &'life1 AttachmentHolder, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Removes every attachment of holder; returns how many.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§