Struct FallbackKeyProvider
pub struct FallbackKeyProvider<P, F> { /* private fields */ }Expand description
Tries a primary KeyProvider, falling back to a secondary provider
when the primary returns KeyProviderError::NotConfigured.
Other error variants (KeyProviderError::InvalidKey, KeyProviderError::LoadError)
are not retried — they indicate the provider was found but broken.
§Example
use cipherstash_client::zerokms::{
EnvKeyProvider, StaticKeyProvider, FallbackKeyProvider, KeyProvider, ClientKey,
};
use uuid::Uuid;
// Try env vars first, fall back to a static key
let provider = FallbackKeyProvider::new(
EnvKeyProvider,
StaticKeyProvider::new(fallback_key),
);
let key = provider.client_key().await.unwrap();Implementations§
§impl<P: KeyProvider, F: KeyProvider> FallbackKeyProvider<P, F>
impl<P: KeyProvider, F: KeyProvider> FallbackKeyProvider<P, F>
pub fn new(primary: P, fallback: F) -> Self
pub fn new(primary: P, fallback: F) -> Self
Create a new FallbackKeyProvider with the given primary and fallback providers.
Trait Implementations§
§impl<P: KeyProvider, F: KeyProvider> KeyProvider for FallbackKeyProvider<P, F>
impl<P: KeyProvider, F: KeyProvider> KeyProvider for FallbackKeyProvider<P, F>
§async fn client_key(&self) -> Result<ClientKey, KeyProviderError>
async fn client_key(&self) -> Result<ClientKey, KeyProviderError>
Load a
ClientKey from this provider.Auto Trait Implementations§
impl<P, F> Freeze for FallbackKeyProvider<P, F>
impl<P, F> RefUnwindSafe for FallbackKeyProvider<P, F>where
P: RefUnwindSafe,
F: RefUnwindSafe,
impl<P, F> Send for FallbackKeyProvider<P, F>
impl<P, F> Sync for FallbackKeyProvider<P, F>
impl<P, F> Unpin for FallbackKeyProvider<P, F>
impl<P, F> UnsafeUnpin for FallbackKeyProvider<P, F>where
P: UnsafeUnpin,
F: UnsafeUnpin,
impl<P, F> UnwindSafe for FallbackKeyProvider<P, F>where
P: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
impl<T> AuthStrategyBounds for T
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