pub struct StrongKey<T>(/* private fields */);Expand description
Wrapper around keys allowing to enforce key strength requirements.
The wrapper signifies that the key has supported strength as per the corresponding
algorithm spec. For example, RSA keys must have length at least 2,048 bits per RFC 7518.
Likewise, HS* keys must have at least the length of the hash output
(e.g., 32 bytes for HS256). Since these requirements sometimes clash with backward
compatibility (and sometimes a lesser level of security is enough),
notion of key strength is implemented in such an opt-in, composable way.
It’s easy to convert a StrongKey<T> to T via into_inner() or to
access &T via AsRef impl. In contrast, the reverse transformation is fallible, and
is defined with the help of TryFrom. The error type for TryFrom is WeakKeyError,
a simple wrapper around a weak key.
§Examples
See StrongAlg docs for an example of usage.
Implementations§
Source§impl<T> StrongKey<T>
impl<T> StrongKey<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Returns the wrapped value.
Trait Implementations§
impl<T> Copy for StrongKey<T>where
T: Copy,
impl<T> Eq for StrongKey<T>where
T: Eq,
impl<T> StructuralPartialEq for StrongKey<T>
Auto Trait Implementations§
impl<T> Freeze for StrongKey<T>where
T: Freeze,
impl<T> RefUnwindSafe for StrongKey<T>where
T: RefUnwindSafe,
impl<T> Send for StrongKey<T>where
T: Send,
impl<T> Sync for StrongKey<T>where
T: Sync,
impl<T> Unpin for StrongKey<T>where
T: Unpin,
impl<T> UnwindSafe for StrongKey<T>where
T: UnwindSafe,
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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§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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.