Skip to main content

SecretEntry

Struct SecretEntry 

Source
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

  • Debug output redacts every field value and the scope; it shows the name, type, provider and field keys.
  • Drop zeroizes every field value and key, the provider and the scope before deallocation, and with_field, with_provider and with_scope zeroize whatever they replace.
  • Clone is supported but creates a second copy of sensitive data in memory — use sparingly and drop clones promptly.
  • PartialEq / Eq are intentionally not implemented to prevent accidental non-constant-time comparisons of secret material.

Implementations§

Source§

impl SecretEntry

Source

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"));
Source

pub fn name(&self) -> &str

Returns the name of this secret.

Source

pub fn secret_type(&self) -> &str

Returns the secret type (e.g., "bearer", "s3", "gcs").

Source

pub fn provider(&self) -> &str

Returns the provider that created this secret.

Source

pub fn scope(&self) -> &str

Returns the scope this secret applies to.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_field(&self, key: &str) -> Option<&str>

Returns the value of a field, if present.

Source

pub fn field_count(&self) -> usize

Returns the number of fields in this secret entry.

Source

pub fn is_empty(&self) -> bool

Returns true if this entry has no fields.

Trait Implementations§

Source§

impl Clone for SecretEntry

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for SecretEntry

Source§

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

Formats the secret entry with field values and the scope redacted.

Field keys are shown; every value, and the scope (a bucket or URL prefix is itself sensitive context, which is why Drop zeroizes it), is replaced with "[REDACTED]". Use get_field and scope to read them in code.

Source§

impl Display for SecretEntry

Source§

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

Formats a human-readable summary without exposing any secret values.

Source§

impl Drop for SecretEntry

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.