Skip to main content

Key

Struct Key 

Source
pub struct Key<const N: usize>(/* private fields */);
Expand description

定长密钥(如 Key<32>、Key<16>)。构造后不可变。

Implementations§

Source§

impl<const N: usize> Key<N>

Source

pub fn new(bytes: [u8; N]) -> Self

Source

pub fn from_slice(bytes: &[u8], label: &'static str) -> Result<Self>

从切片构造;长度不符返回 Error::InvalidKeyLength。

Source

pub fn as_bytes(&self) -> &[u8; N]

Trait Implementations§

Source§

impl<const N: usize> Debug for Key<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Drop for Key<N>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Key<N>
where [u8; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for Key<N>
where [u8; N]: RefUnwindSafe,

§

impl<const N: usize> Send for Key<N>
where [u8; N]: Send,

§

impl<const N: usize> Sync for Key<N>
where [u8; N]: Sync,

§

impl<const N: usize> Unpin for Key<N>
where [u8; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for Key<N>
where [u8; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for Key<N>
where [u8; N]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromExt for T

Source§

fn from_<T>(t: T) -> Self
where Self: From<T>,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoExt for T

Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T> TryFromExt for T

Source§

fn try_from_<T>(t: T) -> Result<Self, Self::Error>
where Self: TryFrom<T>,

Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TryIntoExt for T

Source§

fn try_into_<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,