use zerocopy::{ByteHash, Immutable, IntoBytes, KnownLayout, TryFromBytes, Unaligned};
use crate::core::gid::prefix::ConstDefault;
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
ByteHash,
IntoBytes,
TryFromBytes,
Immutable,
KnownLayout,
Unaligned,
)]
#[repr(C)]
pub struct GidRandom {
data: [u8; 9],
}
impl ConstDefault for GidRandom {
const DEFAULT: Self = Self { data: [0x80, 0, 0, 0, 0, 0, 0, 0, 0] };
}
impl GidRandom {
pub fn random() -> Self {
let mut data: [u8; 9] = rand::random();
data[0] |= 0x80;
Self { data }
}
}