pub struct SharedSecretGroup { /* private fields */ }Expand description
An ordered group of typed values holding at most one entry per CryptoKind.
Entries are kept sorted by kind so the first is the most-preferred cryptosystem.
Adding a value whose kind is already present replaces that entry.
Derefs to a [..] slice, so slice methods like first and iter are available.
Implementations§
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
An empty group with room preallocated for cap entries.
Sourcepub fn iter(&self) -> Iter<'_, SharedSecret>
pub fn iter(&self) -> Iter<'_, SharedSecret>
Iterates the entries in kind-sorted order.
Sourcepub fn add_all_from_iter<'a>(
&mut self,
typed_keys: impl IntoIterator<Item = &'a SharedSecret>,
)
pub fn add_all_from_iter<'a>( &mut self, typed_keys: impl IntoIterator<Item = &'a SharedSecret>, )
Adds or replaces each value by kind, then re-sorts.
Sourcepub fn contains_any_from_iter<'a>(
&self,
typed_keys: impl IntoIterator<Item = &'a SharedSecret>,
) -> bool
pub fn contains_any_from_iter<'a>( &self, typed_keys: impl IntoIterator<Item = &'a SharedSecret>, ) -> bool
Whether any of the given values is present in the group.
Sourcepub fn get(&self, kind: CryptoKind) -> Option<SharedSecret>
pub fn get(&self, kind: CryptoKind) -> Option<SharedSecret>
The entry for the given kind, if present.
Sourcepub fn contains_kind(&self, kind: CryptoKind) -> bool
pub fn contains_kind(&self, kind: CryptoKind) -> bool
Whether the group holds an entry for the given kind.
Sourcepub fn remove(&mut self, kind: CryptoKind) -> Option<SharedSecret>
pub fn remove(&mut self, kind: CryptoKind) -> Option<SharedSecret>
Removes and returns the entry for the given kind, if present.
Sourcepub fn remove_all(&mut self, kinds: Vec<CryptoKind>)
pub fn remove_all(&mut self, kinds: Vec<CryptoKind>)
Removes the entries for all of the given kinds.
Sourcepub fn kinds(&self) -> Vec<CryptoKind>
pub fn kinds(&self) -> Vec<CryptoKind>
The kinds present in the group, sorted by cryptosystem preference.
Sourcepub fn keys(&self) -> Vec<BareSharedSecret>
pub fn keys(&self) -> Vec<BareSharedSecret>
The untagged values of every entry, in kind-sorted order.
Sourcepub fn contains(&self, typed_key: &SharedSecret) -> bool
pub fn contains(&self, typed_key: &SharedSecret) -> bool
Whether the group contains the given value.
Sourcepub fn contains_any(&self, typed_keys: Vec<SharedSecret>) -> bool
pub fn contains_any(&self, typed_keys: Vec<SharedSecret>) -> bool
Whether any of the given values is present in the group.
Sourcepub fn to_vec(&self) -> Vec<SharedSecret>
pub fn to_vec(&self) -> Vec<SharedSecret>
A copy of the entries as a vector, in kind-sorted order.
Sourcepub fn add(&mut self, typed_key: SharedSecret)
pub fn add(&mut self, typed_key: SharedSecret)
Adds a value, or replaces the existing entry of the same kind, then re-sorts.
Sourcepub fn add_all(&mut self, typed_keys: Vec<SharedSecret>)
pub fn add_all(&mut self, typed_keys: Vec<SharedSecret>)
Adds or replaces each value by kind, then re-sorts.
Methods from Deref<Target = [SharedSecret]>§
Trait Implementations§
Source§fn clone(&self) -> SharedSecretGroup
fn clone(&self) -> SharedSecretGroup
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn default() -> SharedSecretGroup
fn default() -> SharedSecretGroup
Source§type Target = [SharedSecret]
type Target = [SharedSecret]
Source§fn deref(&self) -> &[SharedSecret]
fn deref(&self) -> &[SharedSecret]
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§fn from(x: &[SharedSecret]) -> Self
fn from(x: &[SharedSecret]) -> Self
Source§fn from(x: SharedSecret) -> Self
fn from(x: SharedSecret) -> Self
Source§fn from(val: SharedSecretGroup) -> Self
fn from(val: SharedSecretGroup) -> Self
Source§fn from(x: Vec<SharedSecret>) -> Self
fn from(x: Vec<SharedSecret>) -> Self
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)
fn get_heap_size_with_tracker<TRACKER: GetSizeTracker>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreSource§fn cmp(&self, other: &SharedSecretGroup) -> Ordering
fn cmp(&self, other: &SharedSecretGroup) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CmpAssign for Twhere
T: Ord,
impl<T> CmpAssign for Twhere
T: Ord,
Source§fn min_assign(&mut self, other: T)
fn min_assign(&mut self, other: T)
self with other if other is smaller.Source§fn max_assign(&mut self, other: T)
fn max_assign(&mut self, other: T)
self with other if other is larger.Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
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>
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