Skip to main content

lingxia_platform/traits/
secure_store.rs

1use crate::error::PlatformError;
2
3pub trait SecureStore: Send + Sync + 'static {
4    /// Read a persisted value from a secure, app-scoped store that survives reinstall where supported.
5    fn read(&self, key: &str) -> Result<Option<Vec<u8>>, PlatformError> {
6        Err(PlatformError::NotSupported(format!(
7            "SecureStore::read not implemented for key {}",
8            key
9        )))
10    }
11
12    /// Check whether a value exists in the secure store.
13    fn contains(&self, key: &str) -> Result<bool, PlatformError> {
14        Ok(self.read(key)?.is_some())
15    }
16
17    /// Persist a value into the secure store.
18    fn write(&self, key: &str, value: &[u8]) -> Result<(), PlatformError> {
19        let _ = (key, value);
20        Err(PlatformError::NotSupported(
21            "SecureStore::write not implemented".to_string(),
22        ))
23    }
24
25    /// Delete a value from the secure store.
26    fn delete(&self, key: &str) -> Result<(), PlatformError> {
27        Err(PlatformError::NotSupported(format!(
28            "SecureStore::delete not implemented for key {}",
29            key
30        )))
31    }
32}