use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter, Result as FmtResult};
use uuid::Uuid;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct LeaseToken(pub Uuid);

impl LeaseToken {
    pub fn new() -> Self {
        Self(Uuid::new_v4())
    }
}

impl Default for LeaseToken {
    fn default() -> Self {
        Self::new()
    }
}

impl Display for LeaseToken {
    fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
        write!(f, "{}", self.0)
    }
}
