uuid.rs
459 Bytes
use std::fmt::Display;
#[derive(Clone,Copy,Debug)]
pub struct Uuid(pub uuid::Uuid);
impl Display for Uuid {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
macro_rules! ns {
($n:expr) => {
uuid::Uuid::new_v5(&uuid::Uuid::NAMESPACE_DNS, $n.as_bytes())
}
}
impl Uuid {
pub fn get(ns: &str, buf: &mut [u8]) -> Self {
Self(uuid::Uuid::new_v5(&ns!(ns), buf))
}
}