1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::fmt::Display;
use uuid::Uuid;

static PREFIX: &str = "role-";

#[derive(Debug)]
pub struct RoleId {
    pub id: Uuid,
}

impl Default for RoleId {
    fn default() -> Self {
        Self { id: Uuid::now_v7() }
    }
}

impl Display for RoleId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&format!("{PREFIX}{}", self.id))
    }
}

impl From<Uuid> for RoleId {
    fn from(id: Uuid) -> Self {
        RoleId { id }
    }
}