Skip to main content

whatsapp_rust/store/
mod.rs

1pub mod commands;
2pub mod error;
3pub mod persistence_manager;
4pub mod signal;
5pub mod signal_adapter;
6pub mod signal_cache;
7pub mod traits;
8
9// Re-export from the sqlite-storage crate when the feature is enabled
10#[cfg(feature = "sqlite-storage")]
11pub use whatsapp_rust_sqlite_storage::SqliteStore;
12
13pub use crate::store::traits::*;
14use std::ops::{Deref, DerefMut};
15use std::sync::Arc;
16
17#[derive(Clone)]
18pub struct Device {
19    pub core: wacore::store::Device,
20    pub backend: Arc<dyn Backend>,
21}
22
23impl Deref for Device {
24    type Target = wacore::store::Device;
25
26    fn deref(&self) -> &Self::Target {
27        &self.core
28    }
29}
30
31impl DerefMut for Device {
32    fn deref_mut(&mut self) -> &mut Self::Target {
33        &mut self.core
34    }
35}
36
37impl Device {
38    pub fn new(backend: Arc<dyn Backend>) -> Self {
39        let core = wacore::store::Device::new();
40        Self { core, backend }
41    }
42
43    pub fn to_serializable(&self) -> wacore::store::Device {
44        self.core.clone()
45    }
46
47    pub fn load_from_serializable(&mut self, loaded: wacore::store::Device) {
48        self.core = loaded;
49    }
50}