pub struct SecretsManager { /* private fields */ }Expand description
Main secrets manager that handles caching and backend abstraction
Implementations§
Source§impl SecretsManager
impl SecretsManager
Sourcepub fn new(backend: Arc<dyn SecretBackend>, cache_ttl: Duration) -> Self
pub fn new(backend: Arc<dyn SecretBackend>, cache_ttl: Duration) -> Self
Create a new secrets manager with a specific backend
Sourcepub async fn from_config(config: SecretsConfig) -> Result<Self>
pub async fn from_config(config: SecretsConfig) -> Result<Self>
Create from configuration
Sourcepub async fn from_env() -> Result<Self>
pub async fn from_env() -> Result<Self>
Create from environment variables
Uses environment backend by default.
Sourcepub async fn get(&self, key: &str) -> Result<String>
pub async fn get(&self, key: &str) -> Result<String>
Get a secret by key
Checks cache first, then falls back to backend.
Sourcepub async fn get_as<T>(&self, key: &str) -> Result<T>
pub async fn get_as<T>(&self, key: &str) -> Result<T>
Get a secret and parse it to a specific type
§Example
let port: u16 = secrets.get_as("database_port").await?;
let timeout: f64 = secrets.get_as("request_timeout").await?;Sourcepub async fn set(&self, key: &str, value: &str) -> Result<()>
pub async fn set(&self, key: &str, value: &str) -> Result<()>
Set a secret (if backend supports it)
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the cache
Sourcepub async fn invalidate(&self, key: &str)
pub async fn invalidate(&self, key: &str)
Invalidate a specific cache entry
Auto Trait Implementations§
impl Freeze for SecretsManager
impl !RefUnwindSafe for SecretsManager
impl Send for SecretsManager
impl Sync for SecretsManager
impl Unpin for SecretsManager
impl !UnwindSafe for SecretsManager
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
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