Struct distant_net::common::authentication::Keychain
source · 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
sourceimpl<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
sourceimpl<T> From<HashMap<String, (HeapSecretKey, T), RandomState>> for Keychain<T>
impl<T> From<HashMap<String, (HeapSecretKey, T), RandomState>> for Keychain<T>
sourcefn from(map: HashMap<String, (HeapSecretKey, T)>) -> Self
fn from(map: HashMap<String, (HeapSecretKey, T)>) -> Self
Creates a new keychain populated with the provided map.
sourceimpl From<HashMap<String, HeapSecretKey, RandomState>> for Keychain<()>
impl From<HashMap<String, HeapSecretKey, RandomState>> for Keychain<()>
sourcefn from(map: HashMap<String, HeapSecretKey>) -> Self
fn from(map: HashMap<String, HeapSecretKey>) -> Self
Creates a new keychain populated with the provided map.
Auto Trait Implementations
impl<T = ()> !RefUnwindSafe for Keychain<T>
impl<T> Send for Keychain<T>where
T: Send + Sync,
impl<T> Sync for Keychain<T>where
T: Send + Sync,
impl<T> Unpin for Keychain<T>
impl<T = ()> !UnwindSafe for Keychain<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more