Skip to main content

SqliteStore

Struct SqliteStore 

Source
pub struct SqliteStore { /* private fields */ }

Implementations§

Source§

impl SqliteStore

Source

pub fn shared(&self) -> SharedSqlite

Handle for sibling crates to run their own queries and migrations against this store’s database file through the same pool and semaphore.

Source§

impl SqliteStore

Source

pub async fn new(database_url: &str) -> Result<Self, StoreError>

Open a store with the default low-memory SqliteStoreConfig.

Source

pub async fn with_config( database_url: &str, config: SqliteStoreConfig, ) -> Result<Self, StoreError>

Open a store with a custom SqliteStoreConfig (the default favours low memory / high session density; override to trade memory for concurrency or cache).

Source

pub async fn new_for_device( database_url: &str, device_id: i32, ) -> Result<Self, StoreError>

Source

pub async fn with_config_for_device( database_url: &str, device_id: i32, config: SqliteStoreConfig, ) -> Result<Self, StoreError>

Open a store for a specific device with a custom SqliteStoreConfig.

Source

pub fn device_id(&self) -> i32

Source

pub async fn save_device_data_for_device( &self, device_id: i32, device_data: &CoreDevice, ) -> Result<()>

Source

pub async fn create_new_device(&self) -> Result<i32>

Source

pub async fn device_exists(&self, device_id: i32) -> Result<bool>

Source

pub async fn load_device_data_for_device( &self, device_id: i32, ) -> Result<Option<CoreDevice>>

Source

pub async fn put_identity_for_device( &self, address: &str, key: [u8; 32], device_id: i32, ) -> Result<()>

Source

pub async fn delete_identity_for_device( &self, address: &str, device_id: i32, ) -> Result<()>

Source

pub async fn load_identity_for_device( &self, address: &str, device_id: i32, ) -> Result<Option<Vec<u8>>>

Source

pub async fn get_session_for_device( &self, address: &str, device_id: i32, ) -> Result<Option<Vec<u8>>>

Source

pub async fn put_session_for_device( &self, address: &str, session: &[u8], device_id: i32, ) -> Result<()>

Source

pub async fn delete_session_for_device( &self, address: &str, device_id: i32, ) -> Result<()>

Source

pub async fn put_sender_key_for_device( &self, address: &str, record: &[u8], device_id: i32, ) -> Result<()>

Source

pub async fn get_sender_key_for_device( &self, address: &str, device_id: i32, ) -> Result<Option<Vec<u8>>>

Source

pub async fn delete_sender_key_for_device( &self, address: &str, device_id: i32, ) -> Result<()>

Source

pub async fn get_app_state_sync_key_for_device( &self, key_id: &[u8], device_id: i32, ) -> Result<Option<AppStateSyncKey>>

Source

pub async fn set_app_state_sync_key_for_device( &self, key_id: &[u8], key: AppStateSyncKey, device_id: i32, ) -> Result<()>

Source

pub async fn get_latest_app_state_sync_key_id_for_device( &self, device_id: i32, ) -> Result<Option<Vec<u8>>>

Source

pub async fn get_app_state_version_for_device( &self, name: &str, device_id: i32, ) -> Result<HashState>

Source

pub async fn set_app_state_version_for_device( &self, name: &str, state: HashState, device_id: i32, ) -> Result<()>

Source

pub async fn put_app_state_mutation_macs_for_device( &self, name: &str, version: u64, mutations: &[AppStateMutationMAC], device_id: i32, ) -> Result<()>

Source

pub async fn delete_app_state_mutation_macs_for_device( &self, name: &str, index_macs: &[Vec<u8>], device_id: i32, ) -> Result<()>

Source

pub async fn get_app_state_mutation_mac_for_device( &self, name: &str, index_mac: &[u8], device_id: i32, ) -> Result<Option<Vec<u8>>>

Source

pub async fn get_app_state_mutation_macs_batch_for_device( &self, name: &str, index_macs: &[[u8; 32]], device_id: i32, ) -> Result<HashMap<[u8; 32], Vec<u8>>>

Batched read of previous-MAC values for many index_macs in one query (single spawn_blocking + index_mac IN (...)), replacing the per-mutation N+1 in appstate sync.

Trait Implementations§

Source§

impl AppSyncStore for SqliteStore

Source§

fn get_sync_key<'life0, 'life1, 'async_trait>( &'life0 self, key_id: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<AppStateSyncKey>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an app state sync key by ID.
Source§

fn set_sync_key<'life0, 'life1, 'async_trait>( &'life0 self, key_id: &'life1 [u8], key: AppStateSyncKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set an app state sync key.
Source§

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

Get the app state version for a collection.
Source§

fn set_version<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, state: HashState, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Set the app state version for a collection.
Source§

fn put_mutation_macs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, version: u64, mutations: &'life2 [AppStateMutationMAC], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store mutation MACs for a version.
Source§

fn get_mutation_mac<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, index_mac: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get a mutation MAC by index.
Source§

fn get_mutation_macs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, index_macs: &'life2 [[u8; 32]], ) -> Pin<Box<dyn Future<Output = Result<HashMap<[u8; 32], Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batch variant of get_mutation_mac: fetch many previous-MAC values in a single backend round-trip. The default delegates to per-item lookups; backends with a set-membership query (SQL IN (...)) should override to avoid an N+1 (one DB round-trip per mutation in appstate sync). Read more
Source§

fn delete_mutation_macs<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, index_macs: &'life2 [Vec<u8>], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete mutation MACs by their index MACs.
Source§

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

Delete every mutation MAC for a collection. Called on snapshot re-sync so the MAC store is rebuilt from the snapshot, matching the ltHash baseline; leftover entries would corrupt the next patch’s ltHash.
Source§

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

Get the most recently stored app state sync key ID.
Source§

impl Clone for SqliteStore

Source§

fn clone(&self) -> SqliteStore

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl DeviceStore for SqliteStore

Source§

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

Per-session storage memory, the largest per-session chunk in the profiling that motivated this (the default 512 KiB page cache).

SQLite’s exact cache-in-use (sqlite3_db_status(SQLITE_DBSTATUS_CACHE_USED)) needs the raw sqlite3* handle, which Diesel does not expose through a safe API. Instead we bound it with PRAGMAs: a connection’s page cache never holds more than the database’s own pages, nor more than the configured cap, so min(cache cap, db size) is a tight per-connection upper bound for the target workload (a fresh per-session DB far smaller than the 512 KiB cap). Each pooled connection keeps its OWN cache (no shared cache), so the figure is scaled by the number of open connections — a no-op for the default single-connection store. pages is the database page count (a size indicator, shared across connections).

Caveat: this does not account for SqliteStoreConfig::mmap_size. With mmap enabled, some reads bypass the heap page cache via an OS-reclaimable file mapping, so the estimate can overstate actual process-heap residency for that session.

Source§

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

Save device data.
Source§

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

Load device data.
Source§

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

Check if a device exists.
Source§

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

Create a new device row and return its generated device_id.
Source§

fn snapshot_db<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, extra_content: Option<&'life2 [u8]>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Create a snapshot of the database state. The argument name can be used to label the snapshot file. extra_content can be used to save a related binary blob (e.g. the message that caused the failure).
Source§

impl MsgSecretStore for SqliteStore

Source§

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

Batched upsert carrying a per-row expires_at deadline. On key conflict implementations merge deterministically via merge_msg_secret_expiry (later deadline wins, 0 = “never” = infinity) so a redelivery or edit re-persist never shortens a window, and via merge_msg_secret_message_ts (the later non-zero parent time wins; a 0 never clobbers a known one).
Source§

fn get_msg_secret<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, msg_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Fetch the persisted secret; returns None if absent.
Source§

fn get_msg_secret_with_ts<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, msg_id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8>, i64)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Fetch the secret together with the parent message’s event time (message_ts, 0 when unknown), so the receive path can enforce the edit-processing window. Default pairs get_msg_secret with 0; backends that store message_ts override this.
Source§

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

Delete rows whose non-zero expires_at is at or before cutoff_timestamp (absolute unix seconds; callers pass “now”). Rows with expires_at = 0 (never) are kept. Returns the number removed so the keepalive cleanup can log/throttle.
Source§

fn put_msg_secret<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, msg_id: &'life3 str, secret: &'life4 [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Persist the protocol-sized secret under the composite key with NO expiry (expires_at = 0). Convenience wrapper over put_msg_secrets. chat, sender, and msg_id are JID strings / message ID strings; callers should pass non-AD (no-device) form for the JIDs so lookups match regardless of which device echo’d the stanza back. Read more
Source§

impl ProtocolStore for SqliteStore

Source§

fn get_sender_key_devices<'life0, 'life1, 'async_trait>( &'life0 self, group_jid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, bool)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the sender key distribution status for all known devices in a group. Returns (device_jid_string, has_key) pairs where has_key indicates whether the device has a valid sender key (true) or needs fresh SKDM (false).
Source§

fn set_sender_key_status<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, group_jid: &'life1 str, entries: &'life2 [(&'life3 str, bool)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Set sender key status for devices. Called with has_key=true after successful SKDM distribution (WA Web: markHasSenderKey), or has_key=false to mark devices as needing fresh SKDM (WA Web: markForgetSenderKey).
Source§

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

Clear all sender key device tracking for a group (on sender key rotation).
Source§

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

Clear all sender key device tracking across ALL groups. Called on identity change (raw_id mismatch) to force SKDM redistribution.
Source§

fn delete_sender_key_device_rows<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, device_jids: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete specific sender_key_devices rows by device JID across all groups. Mirrors WA Web’s per-group senderKey.delete(deviceJid) cleanup.
Source§

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

Get a mapping by LID.
Source§

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

Get a mapping by phone number (returns the most recent LID for that phone).
Source§

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

Store or update a LID-PN mapping.
Source§

fn put_lid_mappings<'life0, 'life1, 'async_trait>( &'life0 self, entries: &'life1 [LidPnMappingEntry], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Batched variant of put_lid_mapping. Backends should override with a single transaction; the default loops for correctness. Mirrors WA Web’s WAWebDBCreateLidPnMappings.createLidPnMappings({ mappings, … }).
Source§

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

Get all LID-PN mappings (for cache warm-up).
Source§

fn save_base_key<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, address: &'life1 str, message_id: &'life2 str, base_key: &'life3 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Save the base key for a session address during retry collision detection.
Source§

fn has_same_base_key<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, address: &'life1 str, message_id: &'life2 str, current_base_key: &'life3 [u8], ) -> 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,

Check if the current session has the same base key as the saved one.
Source§

fn delete_base_key<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, address: &'life1 str, message_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete a base key entry.
Source§

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

Update the device list for a user (called after usync responses).
Source§

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

Batched variant of update_device_list. Backends should override with a single transaction; the default loops for correctness. Important on usync of large groups, where the per-row commit + spawn_blocking overhead dominates wall-clock time when called once per participant.
Source§

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

Get all known devices for a user.
Source§

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

Delete a device list record, forcing a network re-fetch on next query.
Source§

fn get_group_metadata<'life0, 'life1, 'async_trait>( &'life0 self, group_jid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the persisted, opaque serialized group metadata blob for group_jid. The blob is a caller-serialized GroupInfo snapshot; backends without group persistence return None (the group is then re-queried in full).
Source§

fn put_group_metadata<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, group_jid: &'life1 str, blob: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persist (upsert) the serialized group metadata blob for group_jid. No-op by default; backends override to enable the phash re-query skip.
Source§

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

Remove the persisted group metadata blob for group_jid (e.g. on leave), so the next query re-fetches in full instead of comparing a stale phash. No-op by default.
Source§

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

Get a trusted contact token for a JID (stored under LID).
Source§

fn put_tc_token<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, jid: &'life1 str, entry: &'life2 TcTokenEntry, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store or update a trusted contact token for a JID.
Source§

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

Delete a trusted contact token for a JID.
Source§

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

Get all JIDs that have stored tc tokens.
Source§

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

Delete tc tokens that have no live state left. A row is removed only when its received token is expired-or-absent (token_timestamp < token_cutoff or empty) and its sender bucket is expired-or-absent (sender_timestamp < sender_cutoff or null), so recent sender state is never dropped just because the received token expired. Returns count deleted.
Source§

fn store_received_tc_token<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, jid: &'life1 str, token: &'life2 [u8], token_timestamp: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a token received from a contact, preserving any existing sender_timestamp. The symmetric counterpart of touch_tc_token_sender_timestamp: each writer owns its own field, so the notification path never drops a sender bucket that the issuance path wrote concurrently. Read more
Source§

fn touch_tc_token_sender_timestamp<'life0, 'life1, 'async_trait>( &'life0 self, jid: &'life1 str, sender_timestamp: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Advance sender_timestamp toward sender_timestamp for a contact, inserting a byte-less placeholder when absent and preserving any existing token bytes. The stored value only ever moves forward (max), so concurrent writers (post-send issuance, history sync) converge regardless of ordering and never regress the sender bucket. Read more
Source§

fn store_sent_message<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, chat_jid: &'life1 str, message_id: &'life2 str, payload: &'life3 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Store a sent message’s serialized payload for retry handling. Called after each send_message(); the payload is the protobuf-encoded Message.
Source§

fn take_sent_message<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, chat_jid: &'life1 str, message_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Retrieve and delete a sent message (atomic take). Returns serialized payload. Called when a retry receipt arrives; consuming prevents double-retry.
Source§

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

Delete sent messages older than cutoff (unix timestamp seconds). Returns count deleted.
Source§

fn store_pending_inbound<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, id: &'life3 str, message: &'life4 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Persist a decrypted inbound message awaiting a durability-hook commit. Scoped by (chat, sender, id) because stanza ids are only unique within a (chat, sender).
Source§

fn get_pending_inbound<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Read a buffered inbound message by (chat, sender, id) without removing it.
Source§

fn delete_pending_inbound<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, chat: &'life1 str, sender: &'life2 str, id: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Remove a buffered inbound message once its durability hook has committed.
Source§

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

Delete buffered inbound messages older than cutoff (unix seconds). Returns count deleted. Unlike the other defaults this is a benign Ok(0): the keepalive sweep calls it unconditionally for every backend, so it must not error when the buffer is unsupported.
Source§

fn store_pending_inbound_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, rows: &'life1 [PendingInboundRow<'life2>], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batched store_pending_inbound: the offline drain buffers one commit-batch of messages per call, so backends should override this with a single transaction (the bundled SqliteStore does). The default iterates the single-row method, preserving behavior for third-party backends.
Source§

fn delete_pending_inbound_batch<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, keys: &'life1 [PendingInboundKey<'life2>], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Batched delete_pending_inbound; same override guidance as store_pending_inbound_batch.
Source§

impl SignalStore for SqliteStore

Source§

fn put_identity<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, key: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store an identity key for a remote address.
Source§

fn put_identities_batch<'life0, 'life1, 'async_trait>( &'life0 self, identities: &'life1 [(Arc<str>, [u8; 32])], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store multiple identity keys in a single batch operation. Default implementation falls back to individual put_identity calls. Addresses are Arc<str> so callers (the flush path) pass shared keys without allocating a String per entry.
Source§

fn load_identity<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<[u8; 32]>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load an identity key for a remote address (always 32 bytes).
Source§

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

Delete an identity key.
Source§

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

Get an encrypted session for an address.
Source§

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

Check if a session exists. Default implementation uses get_session.
Source§

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

Whether any session or identity exists for user across all device ids. Addresses are keyed user@server (device 0) or user:dev@server. Used to skip the per-device PN->LID migration scan for users we’ve never had Signal state with. Default is conservative (true) so a backend that doesn’t implement it keeps the caller’s full per-device scan.
Source§

fn put_session<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, address: &'life1 str, session: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store an encrypted session.
Source§

fn put_sessions_batch<'life0, 'life1, 'async_trait>( &'life0 self, sessions: &'life1 [(Arc<str>, Bytes)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store multiple encrypted sessions in a single batch operation. Default implementation falls back to individual put_session calls.
Source§

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

Delete a session.
Source§

fn store_prekey<'life0, 'life1, 'async_trait>( &'life0 self, id: u32, record: &'life1 [u8], uploaded: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a pre-key.
Source§

fn store_prekeys_batch<'life0, 'life1, 'async_trait>( &'life0 self, keys: &'life1 [(u32, Bytes)], uploaded: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store multiple pre-keys in a single batch operation. Default implementation falls back to individual store_prekey calls.
Source§

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

Load a pre-key by ID.
Source§

fn load_prekeys_batch<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [u32], ) -> Pin<Box<dyn Future<Output = Result<Vec<(u32, Bytes)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Load multiple pre-keys by ID in a single batch operation. Returns only the keys that exist.
Source§

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

Remove a pre-key.
Source§

fn mark_prekeys_uploaded<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [u32], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Mark already-stored pre-keys as uploaded WITHOUT inserting. UPDATE semantics on purpose: a key consumed (deleted) between the upload snapshot and this call must stay deleted, never be resurrected by an upsert.
Source§

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

Get the maximum pre-key ID currently stored, or 0 if none exist. Used for migration when next_pre_key_id counter is not yet initialized.
Source§

fn store_signed_prekey<'life0, 'life1, 'async_trait>( &'life0 self, id: u32, record: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store a signed pre-key.
Source§

fn load_signed_prekey<'life0, 'async_trait>( &'life0 self, id: u32, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load a signed pre-key by ID.
Source§

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

Load all signed pre-keys. Returns (id, record) pairs.
Source§

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

Remove a signed pre-key.
Source§

fn put_sender_key<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, address: &'life1 str, record: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store a sender key for group messaging.
Source§

fn put_sender_keys_batch<'life0, 'life1, 'async_trait>( &'life0 self, sender_keys: &'life1 [(Arc<str>, Bytes)], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Store multiple sender keys in a single batch operation. Default implementation falls back to individual put_sender_key calls.
Source§

fn get_sender_key<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a sender key.
Source§

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

Delete a sender key.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Backend for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Spawnable for T
where T: Send + 'static,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more