1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::ops::{Deref, DerefMut};

#[derive(Debug, Default, Clone, zeroize::ZeroizeOnDrop)]
pub struct ScrubbedBytes(Vec<u8>);

pub type Password = ScrubbedBytes;

impl From<Vec<u8>> for ScrubbedBytes {
    fn from(v: Vec<u8>) -> Self {
        Self(v)
    }
}

impl From<String> for ScrubbedBytes {
    fn from(v: String) -> Self {
        Self(v.into_bytes())
    }
}

impl AsRef<[u8]> for ScrubbedBytes {
    fn as_ref(&self) -> &[u8] {
        self.0.as_ref()
    }
}

impl Deref for ScrubbedBytes {
    type Target = [u8];
    fn deref(&self) -> &Self::Target {
        self.0.deref()
    }
}
impl DerefMut for ScrubbedBytes {
    fn deref_mut(&mut self) -> &mut Self::Target {
        self.0.deref_mut()
    }
}