pub enum SecretValue {
Plain(SecretString),
Environment(String),
HashicorpCloudVault(String),
}
Expand description
A type that represents a secret value that can be sourced from different places and ensures proper zeroization of sensitive data.
This enum provides different ways to store and retrieve secrets:
Plain
: Direct secret value (wrapped inSecretString
for secure memory handling)Environment
: Environment variable referenceHashicorpCloudVault
: Hashicorp Cloud Vault reference
All variants implement ZeroizeOnDrop
to ensure secure memory cleanup.
Variants§
Plain(SecretString)
A plain text secret value
Environment(String)
A secret stored in an environment variable
HashicorpCloudVault(String)
A secret stored in Hashicorp Cloud Vault
Implementations§
Source§impl SecretValue
impl SecretValue
Sourcepub async fn resolve(&self) -> Result<SecretString, Box<SecurityError>>
pub async fn resolve(&self) -> Result<SecretString, Box<SecurityError>>
Resolves the secret value based on its type.
This method retrieves the actual secret value from its source:
- For
Plain
, returns the wrappedSecretString
- For
Environment
, reads the environment variable - For
HashicorpCloudVault
, fetches the secret from the vault
§Errors
Returns a SecurityError
if:
- Environment variable is not set
- Vault access fails
- Any other security-related error occurs
Sourcepub fn starts_with(&self, prefix: &str) -> bool
pub fn starts_with(&self, prefix: &str) -> bool
Checks if the secret value starts with a given prefix
Trait Implementations§
Source§impl AsRef<str> for SecretValue
impl AsRef<str> for SecretValue
Source§impl Clone for SecretValue
impl Clone for SecretValue
Source§fn clone(&self) -> SecretValue
fn clone(&self) -> SecretValue
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SecretValue
impl Debug for SecretValue
Source§impl<'de> Deserialize<'de> for SecretValue
impl<'de> Deserialize<'de> for SecretValue
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for SecretValue
impl Display for SecretValue
Source§impl Drop for SecretValue
impl Drop for SecretValue
Source§impl PartialEq for SecretValue
impl PartialEq for SecretValue
Source§impl Serialize for SecretValue
impl Serialize for SecretValue
Source§impl Zeroize for SecretValue
impl Zeroize for SecretValue
Auto Trait Implementations§
impl Freeze for SecretValue
impl RefUnwindSafe for SecretValue
impl Send for SecretValue
impl Sync for SecretValue
impl Unpin for SecretValue
impl UnwindSafe for SecretValue
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more