pub struct VaultSecrets { /* private fields */ }Expand description
A collection of multiple secrets loaded from a configuration source.
Provides utility methods for accessing secrets by alias and deserializing them into strongly typed values.
Implementations§
Source§impl VaultSecrets
impl VaultSecrets
Sourcepub fn new(data: Vec<VaultSecret>) -> Self
pub fn new(data: Vec<VaultSecret>) -> Self
Creates a new VaultSecrets instance from a given list of secrets.
§Parameters
data: A vector ofVaultSecretitems representing the stored secrets.
§Returns
A VaultSecrets instance containing the provided secrets.
§Example
use cdumay_config::{VaultSecrets, VaultSecret};
let secrets = vec![
VaultSecret::new("api", "api_key", "1234")
];
let vault = VaultSecrets::new(secrets);Sourcepub fn alias<C: DeserializeOwned>(
&self,
name: String,
format: ContentFormat,
context: &BTreeMap<String, Value>,
) -> Result<C>
pub fn alias<C: DeserializeOwned>( &self, name: String, format: ContentFormat, context: &BTreeMap<String, Value>, ) -> Result<C>
Retrieves and deserializes a secret value by its alias.
§Type Parameters
C: The target deserialization type.
§Parameters
name: The alias of the secret to retrieve.format: The format used to deserialize the secret’s value (e.g. JSON, YAML).context: A templating context used for value substitution (e.g. variables).
§Returns
The deserialized secret as type C if successful, or an error
if the alias doesn’t exist or deserialization fails.
§Errors
Returns a VaultSecretError if the alias is not found or deserialization fails.
Trait Implementations§
Source§impl Clone for VaultSecrets
impl Clone for VaultSecrets
Source§fn clone(&self) -> VaultSecrets
fn clone(&self) -> VaultSecrets
Returns a duplicate 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 VaultSecrets
impl Debug for VaultSecrets
Source§impl<'de> Deserialize<'de> for VaultSecrets
impl<'de> Deserialize<'de> for VaultSecrets
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
Auto Trait Implementations§
impl Freeze for VaultSecrets
impl RefUnwindSafe for VaultSecrets
impl Send for VaultSecrets
impl Sync for VaultSecrets
impl Unpin for VaultSecrets
impl UnwindSafe for VaultSecrets
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