pub struct InMemoryKeyResolver { /* private fields */ }Expand description
Thread-safe in-memory KeyResolver backed by a DashMap.
Suitable for tests and single-process deployments where the full key set
fits in memory. For database- or cache-backed production deployments,
implement KeyResolver directly.
The map is stored behind an Arc so that the futures returned by
KeyResolver::resolve are 'static (they capture the Arc by clone,
not a borrow of self).
Implementations§
Source§impl InMemoryKeyResolver
impl InMemoryKeyResolver
Sourcepub fn with_entries(
entries: impl IntoIterator<Item = (String, ResolvedKey)>,
) -> Self
pub fn with_entries( entries: impl IntoIterator<Item = (String, ResolvedKey)>, ) -> Self
Create a resolver pre-populated with the given entries.
Sourcepub fn insert(&self, api_key: impl Into<String>, resolved: ResolvedKey)
pub fn insert(&self, api_key: impl Into<String>, resolved: ResolvedKey)
Insert or replace a key record.
Sourcepub fn remove(&self, api_key: &str) -> Option<ResolvedKey>
pub fn remove(&self, api_key: &str) -> Option<ResolvedKey>
Remove a key record. Returns the removed record if it existed.
Trait Implementations§
Source§impl Default for InMemoryKeyResolver
impl Default for InMemoryKeyResolver
Source§impl KeyResolver for InMemoryKeyResolver
impl KeyResolver for InMemoryKeyResolver
Auto Trait Implementations§
impl !RefUnwindSafe for InMemoryKeyResolver
impl !UnwindSafe for InMemoryKeyResolver
impl Freeze for InMemoryKeyResolver
impl Send for InMemoryKeyResolver
impl Sync for InMemoryKeyResolver
impl Unpin for InMemoryKeyResolver
impl UnsafeUnpin for InMemoryKeyResolver
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