use std::fmt;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::message::Message;
#[derive(Clone, Copy, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd)]
pub struct UUID {
#[serde(with = "uuid::serde::compact")] pub uuid: Uuid,
}
impl Message for UUID {}
impl fmt::Debug for UUID {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(self.uuid.as_simple(), f)
}
}
impl UUID {
pub const ZERO: UUID = UUID { uuid: Uuid::nil() };
pub fn new_random() -> Self {
UUID {
uuid: Uuid::new_v4(),
}
}
}