Common/Secret/DeleteSecret.rs
1//! # DeleteSecret Effect
2//!
3//! Defines the `ActionEffect` for deleting a secret from secure storage.
4
5use std::sync::Arc;
6
7use super::SecretProvider::SecretProvider;
8use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
9
10/// Creates an effect that, when executed, will delete a secret from the host's
11/// secure storage (e.g., OS keychain).
12///
13/// It uses the `SecretProvider` capability from the environment to perform the
14/// actual deletion.
15///
16/// # Parameters
17/// * `ExtensionIdentifier`: The ID of the extension that owns the secret.
18/// * `Key`: The key of the secret to delete.
19///
20/// # Returns
21/// An `ActionEffect` that resolves to `()` on success.
22pub fn DeleteSecret(ExtensionIdentifier:String, Key:String) -> ActionEffect<Arc<dyn SecretProvider>, CommonError, ()> {
23 ActionEffect::New(Arc::new(move |Provider:Arc<dyn SecretProvider>| {
24 let ExtensionIdentifierClone = ExtensionIdentifier.clone();
25
26 let KeyClone = Key.clone();
27
28 Box::pin(async move { Provider.DeleteSecret(ExtensionIdentifierClone, KeyClone).await })
29 }))
30}