#[repr(transparent)]pub struct KeyBytes<const LEN: usize>(pub [u8; LEN]);Expand description
Generic wrapper for a fixed-length array of cryptographic key bytes, convertible to or from a base58-encoded string.
Tuple Fields§
§0: [u8; LEN]Implementations§
Source§impl<const LEN: usize> KeyBytes<LEN>
impl<const LEN: usize> KeyBytes<LEN>
Sourcepub fn new(bytes: [u8; LEN]) -> KeyBytes<LEN>
pub fn new(bytes: [u8; LEN]) -> KeyBytes<LEN>
Construct a new instance from the provided key bytes
Sourcepub fn into_bytes(self) -> [u8; LEN]
pub fn into_bytes(self) -> [u8; LEN]
Return the public key bytes contained in this instance
Sourcepub fn try_from_ref<T>(key: T) -> Result<KeyBytes<LEN>, TryFromSliceError>
pub fn try_from_ref<T>(key: T) -> Result<KeyBytes<LEN>, TryFromSliceError>
Attempt to convert the provided byte slice to a new key byte array
§Errors
This function returns an error if calling KeyBytes::try_from(slice)
returns an error.
Sourcepub fn equals_ref<T>(&self, other: T) -> bool
pub fn equals_ref<T>(&self, other: T) -> bool
Compare the public key bytes contained in this array with the given byte slice
Trait Implementations§
Source§impl<const LEN: usize> BorshDeserialize for KeyBytes<LEN>
impl<const LEN: usize> BorshDeserialize for KeyBytes<LEN>
fn deserialize_reader<R>(reader: &mut R) -> Result<KeyBytes<LEN>, Error>where
R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl<const LEN: usize> BorshSerialize for KeyBytes<LEN>
impl<const LEN: usize> BorshSerialize for KeyBytes<LEN>
impl<const LEN: usize> Copy for KeyBytes<LEN>
impl<const LEN: usize> Eq for KeyBytes<LEN>
impl<const LEN: usize> StructuralPartialEq for KeyBytes<LEN>
Auto Trait Implementations§
impl<const LEN: usize> Freeze for KeyBytes<LEN>
impl<const LEN: usize> RefUnwindSafe for KeyBytes<LEN>
impl<const LEN: usize> Send for KeyBytes<LEN>
impl<const LEN: usize> Sync for KeyBytes<LEN>
impl<const LEN: usize> Unpin for KeyBytes<LEN>
impl<const LEN: usize> UnsafeUnpin for KeyBytes<LEN>
impl<const LEN: usize> UnwindSafe for KeyBytes<LEN>
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
Mutably borrows from an owned value. Read more