pub struct Key { /* private fields */ }Expand description
Base key type backed by exact-size secret storage.
Implementations§
Source§impl Key
impl Key
Sourcepub fn new(data: &[u8]) -> Self
pub fn new(data: &[u8]) -> Self
Copy key bytes directly into exact-size owned storage.
The caller retains responsibility for clearing the source buffer. This
constructor intentionally accepts a slice rather than taking a Vec:
safe Rust cannot inspect or erase a vector’s spare capacity.
Sourcepub fn from_boxed_slice(data: Box<[u8]>) -> Self
pub fn from_boxed_slice(data: Box<[u8]>) -> Self
Take ownership of an exact-size boxed key allocation.
Sourcepub fn from_slice(data: &[u8]) -> Self
pub fn from_slice(data: &[u8]) -> Self
Copy key bytes directly into exact-size owned storage.
pub fn new_zeros(len: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn to_bytes_zeroizing_boxed(&self) -> ZeroizingBytes
pub fn to_bytes_zeroizing_boxed(&self) -> ZeroizingBytes
Serialize into exact-size storage that clears itself on drop.
Trait Implementations§
Source§impl SerializeSecret for Key
impl SerializeSecret for Key
Source§fn from_bytes(bytes: &[u8]) -> Result<Self>
fn from_bytes(bytes: &[u8]) -> Result<Self>
Creates an object from a byte slice. Input should be zeroized after use.
Source§fn to_bytes_zeroizing(&self) -> ZeroizingBytes
fn to_bytes_zeroizing(&self) -> ZeroizingBytes
Converts the object to exact-size bytes that are zeroized on drop.
impl ZeroizeOnDrop for Key
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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