Struct memsecurity::ZeroizeArray
source · pub struct ZeroizeArray<const N: usize>(/* private fields */);
Expand description
This is a array whose size is specified as a const generic N
and can be zeroed out when dropped from memory.
This array is useful when specifying fixed size bytes like passwords which need to be zeroed out from memory before being dropped.
Structure
pub struct ZeroizeArray<const N: usize>([u8; N]);
Implementations§
source§impl<const N: usize> ZeroizeArray<N>
impl<const N: usize> ZeroizeArray<N>
sourcepub fn new(value: [u8; N]) -> Self
pub fn new(value: [u8; N]) -> Self
Initialize a ZeroizeArray with the value of specified by the array of bytes
sourcepub fn new_zeroed() -> Self
pub fn new_zeroed() -> Self
Initialize a new array which is zeroed bytes of len N
as specified by the generic const N: usize
sourcepub fn fill_from_array(self, value: [u8; N]) -> Self
pub fn fill_from_array(self, value: [u8; N]) -> Self
File the current array with new values specified by the method parameter value: [u8; N]
sourcepub fn fill_from_array_borrowed(&mut self, value: [u8; N]) -> &mut Self
pub fn fill_from_array_borrowed(&mut self, value: [u8; N]) -> &mut Self
Fill the current array with new values specified by the method parameter value: [u8; N]
but returing a &mut Self
sourcepub fn new_from_slice(value: &[u8]) -> MemSecurityResult<Self>
pub fn new_from_slice(value: &[u8]) -> MemSecurityResult<Self>
Create array with new values specified by the method parameter value: [u8; N]
sourcepub fn fill_from_slice(self, value: &[u8]) -> MemSecurityResult<Self>
pub fn fill_from_slice(self, value: &[u8]) -> MemSecurityResult<Self>
Fill the current array with new values specified by the method parameter value: [u8; N]
sourcepub fn fill_from_slice_borrowed(
&mut self,
value: &[u8]
) -> MemSecurityResult<&mut Self>
pub fn fill_from_slice_borrowed( &mut self, value: &[u8] ) -> MemSecurityResult<&mut Self>
File the current array with new values specified by the method parameter value: [u8; N]
sourcepub fn expose_borrowed(&self) -> &[u8; N]
pub fn expose_borrowed(&self) -> &[u8; N]
Expose the internal as an borrowed array