pub struct EncryptedStorage<S, C, Sec>{ /* private fields */ }Expand description
Unified encrypted storage that wraps any StorageEffects implementation.
All data passing through this layer is encrypted using a master key stored in the platform’s secure enclave via SecureStorageEffects.
§Type Parameters
S: Inner storage implementation (where encrypted blobs live)C: Crypto implementation (for ChaCha20-Poly1305 operations)Sec: Secure storage implementation (where master key lives)
§Example
ⓘ
let encrypted = EncryptedStorage::new(
filesystem_handler,
crypto_handler,
secure_storage_handler,
EncryptedStorageConfig::default(),
).await?;
// All operations are now transparently encrypted
encrypted.store("accounts", data).await?;
let data = encrypted.retrieve("accounts").await?;Implementations§
Source§impl<S, C, Sec> EncryptedStorage<S, C, Sec>
impl<S, C, Sec> EncryptedStorage<S, C, Sec>
Sourcepub fn new(
inner: S,
crypto: Arc<C>,
secure: Arc<Sec>,
config: EncryptedStorageConfig,
) -> Self
pub fn new( inner: S, crypto: Arc<C>, secure: Arc<Sec>, config: EncryptedStorageConfig, ) -> Self
Create a new encrypted storage handler.
Master key initialization is lazy: the key is loaded/created on the first
store/retrieve/... call. This keeps runtime assembly synchronous and avoids
turning effect-system constructors into async APIs.
Sourcepub fn is_encrypted(blob: &[u8]) -> bool
pub fn is_encrypted(blob: &[u8]) -> bool
Check if a blob is encrypted (has our version header).
Used for detecting unencrypted legacy data.
Trait Implementations§
Source§impl<S, C, Sec> Debug for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Debug,
C: CryptoEffects,
Sec: SecureStorageEffects,
impl<S, C, Sec> Debug for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Debug,
C: CryptoEffects,
Sec: SecureStorageEffects,
Source§impl<S, C, Sec> StorageCoreEffects for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Send + Sync,
C: CryptoEffects + Send + Sync,
Sec: SecureStorageEffects + Send + Sync,
impl<S, C, Sec> StorageCoreEffects for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Send + Sync,
C: CryptoEffects + Send + Sync,
Sec: SecureStorageEffects + Send + Sync,
Source§fn store<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn store<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Store a value under the given key
Source§fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a value by key
Source§impl<S, C, Sec> StorageExtendedEffects for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Send + Sync,
C: CryptoEffects + Send + Sync,
Sec: SecureStorageEffects + Send + Sync,
impl<S, C, Sec> StorageExtendedEffects for EncryptedStorage<S, C, Sec>where
S: StorageCoreEffects + StorageExtendedEffects + Send + Sync,
C: CryptoEffects + Send + Sync,
Sec: SecureStorageEffects + Send + Sync,
Source§fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Check if a key exists
Source§fn store_batch<'life0, 'async_trait>(
&'life0 self,
pairs: HashMap<String, Vec<u8>>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store_batch<'life0, 'async_trait>(
&'life0 self,
pairs: HashMap<String, Vec<u8>>,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store multiple key-value pairs atomically
Source§fn retrieve_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<u8>>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<u8>>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve multiple values by keys
Source§fn clear_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear all stored data
Source§fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StorageStats, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<StorageStats, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get storage statistics
Auto Trait Implementations§
impl<S, C, Sec> !Freeze for EncryptedStorage<S, C, Sec>
impl<S, C, Sec> !RefUnwindSafe for EncryptedStorage<S, C, Sec>
impl<S, C, Sec> Send for EncryptedStorage<S, C, Sec>
impl<S, C, Sec> Sync for EncryptedStorage<S, C, Sec>
impl<S, C, Sec> Unpin for EncryptedStorage<S, C, Sec>where
S: Unpin,
impl<S, C, Sec> UnsafeUnpin for EncryptedStorage<S, C, Sec>where
S: UnsafeUnpin,
impl<S, C, Sec> UnwindSafe for EncryptedStorage<S, C, Sec>
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