Skip to main content

EncryptedStorage

Struct EncryptedStorage 

Source
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>

Source

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.

Source

pub fn is_encrypted(blob: &[u8]) -> bool

Check if a blob is encrypted (has our version header).

Used for detecting unencrypted legacy data.

Source

pub fn inner(&self) -> &S

Get reference to inner storage (for debugging/testing)

Source

pub fn secure(&self) -> &Arc<Sec>

Get reference to secure storage (for key management)

Trait Implementations§

Source§

impl<S, C, Sec> Debug for EncryptedStorage<S, C, Sec>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S, C, Sec> StorageCoreEffects for EncryptedStorage<S, C, Sec>

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,

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,

Retrieve a value by key
Source§

fn remove<'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,

Remove a key-value pair
Source§

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

List all keys with optional prefix filter
Source§

impl<S, C, Sec> StorageExtendedEffects for EncryptedStorage<S, C, Sec>

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,

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,

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,

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,

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,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> StorageEffects for T