pub struct Keychain<T = ()> { /* private fields */ }
Expand description
Manages keys with associated ids. Cloning will result in a copy pointing to the same underlying storage, which enables support of managing the keys across multiple threads.
Implementations§
Source§impl<T> Keychain<T>
impl<T> Keychain<T>
Sourcepub async fn insert(
&self,
id: impl Into<String>,
key: HeapSecretKey,
data: T,
) -> Option<T>
pub async fn insert( &self, id: impl Into<String>, key: HeapSecretKey, data: T, ) -> Option<T>
Stores a new key
and data
by a given id
, returning the old data associated with the
id if there was one already registered.
Sourcepub async fn has_id(&self, id: impl AsRef<str>) -> bool
pub async fn has_id(&self, id: impl AsRef<str>) -> bool
Checks if there is an id
stored within the keychain.
Sourcepub async fn has_key(
&self,
id: impl AsRef<str>,
key: impl PartialEq<HeapSecretKey>,
) -> bool
pub async fn has_key( &self, id: impl AsRef<str>, key: impl PartialEq<HeapSecretKey>, ) -> bool
Checks if there is a key with the given id
that matches the provided key
.
Sourcepub async fn remove(&self, id: impl AsRef<str>) -> Option<T>
pub async fn remove(&self, id: impl AsRef<str>) -> Option<T>
Removes a key and its data by a given id
, returning the data if the id
exists.
Sourcepub async fn remove_if_has_key(
&self,
id: impl AsRef<str>,
key: impl PartialEq<HeapSecretKey>,
) -> KeychainResult<T>
pub async fn remove_if_has_key( &self, id: impl AsRef<str>, key: impl PartialEq<HeapSecretKey>, ) -> KeychainResult<T>
Checks if there is a key with the given id
that matches the provided key
, returning the
data if the id
exists and the key
matches.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Keychain<T>
impl<T = ()> !RefUnwindSafe for Keychain<T>
impl<T> Send for Keychain<T>
impl<T> Sync for Keychain<T>
impl<T> Unpin for Keychain<T>
impl<T = ()> !UnwindSafe for Keychain<T>
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