pub struct SecretEntry { /* private fields */ }Expand description
A single secret entry retrieved from the secrets manager.
Contains the secret’s metadata and key-value pairs. The fields map holds
the actual secret data (e.g., "token", "username", "password",
"client_cert_path").
§Security
Debugoutput redacts every field value and the scope; it shows the name, type, provider and field keys.Dropzeroizes every field value and key, the provider and the scope before deallocation, andwith_field,with_providerandwith_scopezeroize whatever they replace.Cloneis supported but creates a second copy of sensitive data in memory — use sparingly and drop clones promptly.PartialEq/Eqare intentionally not implemented to prevent accidental non-constant-time comparisons of secret material.
Implementations§
Source§impl SecretEntry
impl SecretEntry
Sourcepub fn new(name: impl Into<String>, secret_type: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, secret_type: impl Into<String>) -> Self
Creates a new SecretEntry with the given name and type.
§Example
use quack_rs::secrets::SecretEntry;
let entry = SecretEntry::new("my_api_key", "bearer")
.with_provider("config")
.with_field("token", "sk-abc123");
assert_eq!(entry.name(), "my_api_key");
assert_eq!(entry.get_field("token"), Some("sk-abc123"));Sourcepub fn secret_type(&self) -> &str
pub fn secret_type(&self) -> &str
Returns the secret type (e.g., "bearer", "s3", "gcs").
Sourcepub fn field_keys(&self) -> Vec<&str>
pub fn field_keys(&self) -> Vec<&str>
Returns the field key names without exposing values.
Use this for logging or diagnostics without leaking sensitive data.
Sourcepub fn with_provider(self, provider: impl Into<String>) -> Self
pub fn with_provider(self, provider: impl Into<String>) -> Self
Sets the provider for this secret entry. A provider set earlier is zeroized before its buffer is freed.
Sourcepub fn with_scope(self, scope: impl Into<String>) -> Self
pub fn with_scope(self, scope: impl Into<String>) -> Self
Sets the scope for this secret entry. A scope set earlier is zeroized before its buffer is freed.
Sourcepub fn with_field(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_field( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a key-value field to this secret entry.
Setting a key that is already present replaces its value; the old value is zeroized before its buffer is freed, and so is the duplicate key.
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Returns the number of fields in this secret entry.
Trait Implementations§
Source§impl Clone for SecretEntry
impl Clone for SecretEntry
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Clones this secret entry, duplicating all sensitive material in memory.
Callers should be aware that cloning creates a second copy of secret values. Drop the clone as soon as it is no longer needed to minimize the window during which sensitive data resides in memory.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more