Struct secstr::SecVec
[−]
[src]
pub struct SecVec<T> where
T: Sized + Copy, { /* fields omitted */ }
A data type suitable for storing sensitive information such as passwords and private keys in memory, that implements:
- Automatic zeroing in
Drop
- Constant time comparison in
PartialEq
(does not short circuit on the first different character; but terminates instantly if strings have different length) - Outputting
***SECRET***
to prevent leaking secrets into logs infmt::Debug
andfmt::Display
- Automatic
mlock
to protect against leaking into swap
Be careful with SecStr::from
: if you have a borrowed string, it will be copied.
Use SecStr::new
if you have a Vec<u8>
.
Methods
impl<T> SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
fn new(cont: Vec<T>) -> Self
fn unsecure(&self) -> &[T]
Borrow the contents of the string.
fn unsecure_mut(&mut self) -> &mut [T]
Mutably borrow the contents of the string.
fn zero_out(&mut self)
Overwrite the string with zeros. This is automatically called in the destructor.
Trait Implementations
impl<T: Clone> Clone for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
fn clone(&self) -> SecVec<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Eq> Eq for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T, U> From<U> for SecVec<T> where
U: Into<Vec<T>>,
T: Sized + Copy,
[src]
U: Into<Vec<T>>,
T: Sized + Copy,
impl<T> Borrow<[T]> for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> BorrowMut<[T]> for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
fn borrow_mut(&mut self) -> &mut [T]
Mutably borrows from an owned value. Read more
impl<T> Drop for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> PartialEq for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
fn eq(&self, other: &SecVec<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<T> Debug for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,
impl<T> Display for SecVec<T> where
T: Sized + Copy,
[src]
T: Sized + Copy,