Struct distant_core::SecretKey
source · [−]pub struct SecretKey<const N: usize>(_);Expand description
Represents a secret key used with transport encryption and authentication
Implementations
sourceimpl<const N: usize> SecretKey<N>
impl<const N: usize> SecretKey<N>
sourcepub fn unprotected_as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn unprotected_as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns byte slice to the key’s bytes
sourcepub fn unprotected_as_byte_array(&self) -> &[u8; N]
pub fn unprotected_as_byte_array(&self) -> &[u8; N]
Returns reference to array of key’s bytes
sourcepub fn generate() -> Result<Self, SecretKeyError>
pub fn generate() -> Result<Self, SecretKeyError>
Generates a new secret key, returning success if key created or
failing if the desired key length is not between 1 and isize::MAX
sourcepub fn from_slice(slice: &[u8]) -> Result<Self, SecretKeyError>
pub fn from_slice(slice: &[u8]) -> Result<Self, SecretKeyError>
Creates the key from the given byte slice, returning success if key created or failing if the byte slice does not match the desired key length
Trait Implementations
sourceimpl From<SecretKey<32_usize>> for XChaCha20Poly1305Codec
impl From<SecretKey<32_usize>> for XChaCha20Poly1305Codec
sourcefn from(secret_key: SecretKey32) -> Self
fn from(secret_key: SecretKey32) -> Self
Create a new XChaCha20Poly1305 codec with a 32-byte key
sourceimpl<const N: usize> UnprotectedToHexKey for SecretKey<N>
impl<const N: usize> UnprotectedToHexKey for SecretKey<N>
fn unprotected_to_hex_key(&self) -> String
impl<const N: usize> Eq for SecretKey<N>
impl<const N: usize> StructuralEq for SecretKey<N>
impl<const N: usize> StructuralPartialEq for SecretKey<N>
Auto Trait Implementations
impl<const N: usize> RefUnwindSafe for SecretKey<N>
impl<const N: usize> Send for SecretKey<N>
impl<const N: usize> Sync for SecretKey<N>
impl<const N: usize> Unpin for SecretKey<N>
impl<const N: usize> UnwindSafe for SecretKey<N>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more