pub struct BatchSecrets { /* private fields */ }Expand description
Batch of resolved secrets with per-batch lifetime.
Secrets are automatically zeroed when this struct is dropped. This provides secure handling for secrets resolved ahead of task execution.
§Lifetime
This struct is designed for per-batch use:
- Resolve all secrets needed for a batch of tasks
- Use the secrets during task execution
- Drop the
BatchSecretswhen the batch completes - Memory is automatically zeroed on drop
§Example
ⓘ
let mut batch = BatchSecrets::new();
batch.insert("API_KEY".to_string(), SecureSecret::new("secret".to_string()), None);
// Use during task execution
if let Some(secret) = batch.get("API_KEY") {
std::env::set_var("API_KEY", secret.expose());
}
// When batch goes out of scope, all secrets are zeroedImplementations§
Source§impl BatchSecrets
impl BatchSecrets
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a batch with pre-allocated capacity.
Sourcepub fn insert(
&mut self,
name: String,
value: SecureSecret,
fingerprint: Option<String>,
)
pub fn insert( &mut self, name: String, value: SecureSecret, fingerprint: Option<String>, )
Insert a secret into the batch.
§Arguments
name- The secret name/keyvalue- The secure secret valuefingerprint- Optional HMAC fingerprint for cache key inclusion
Sourcepub fn get(&self, name: &str) -> Option<&SecureSecret>
pub fn get(&self, name: &str) -> Option<&SecureSecret>
Get a secret by name.
Sourcepub const fn fingerprints(&self) -> &HashMap<String, String>
pub const fn fingerprints(&self) -> &HashMap<String, String>
Get the fingerprints map.
Sourcepub fn fingerprint(&self, name: &str) -> Option<&str>
pub fn fingerprint(&self, name: &str) -> Option<&str>
Get the fingerprint for a specific secret.
Sourcepub fn into_env_map(self) -> HashMap<String, String>
pub fn into_env_map(self) -> HashMap<String, String>
Convert to environment variable map for process injection.
§Warning
This exposes all secret values. Use carefully and ensure the resulting map is not logged or persisted.
Sourcepub fn into_resolved_secrets(self) -> ResolvedSecrets
pub fn into_resolved_secrets(self) -> ResolvedSecrets
Convert to ResolvedSecrets for backward compatibility.
This consumes the batch and converts it to the legacy format.
Trait Implementations§
Source§impl Debug for BatchSecrets
impl Debug for BatchSecrets
Source§impl Default for BatchSecrets
impl Default for BatchSecrets
Source§fn default() -> BatchSecrets
fn default() -> BatchSecrets
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for BatchSecrets
impl RefUnwindSafe for BatchSecrets
impl Send for BatchSecrets
impl Sync for BatchSecrets
impl Unpin for BatchSecrets
impl UnsafeUnpin for BatchSecrets
impl UnwindSafe for BatchSecrets
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