use aws_lc_rs::rand;
#[derive(Debug)]
pub struct IdNonce([u8; 16]);
impl Default for IdNonce {
fn default() -> Self {
let mut buf = [0u8; 16];
rand::fill(&mut buf).unwrap();
assert_ne!(buf, [0u8; 16]);
Self(buf)
}
}
impl IdNonce {
pub fn as_bytes(&self) -> &[u8; 16] {
&self.0
}
}
#[cfg(test)]
mod tests {
use super::*;
use static_assertions::assert_not_impl_any;
assert_not_impl_any!(IdNonce: Clone);
#[test]
fn test_nonce_generation() {
assert_eq!(IdNonce::default().as_bytes().len(), 16);
assert_ne!(IdNonce::default().as_bytes(), IdNonce::default().as_bytes());
}
}