datex_core/utils/
uuid.rs

1use crate::crypto::uuid::generate_uuid;
2use crate::stdlib::fmt::Display;
3
4#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub struct UUID(String);
6
7impl UUID {
8    pub fn new() -> UUID {
9        UUID::default()
10    }
11    pub fn from_string(uuid: String) -> UUID {
12        UUID(uuid)
13    }
14}
15
16impl Default for UUID {
17    fn default() -> Self {
18        UUID(generate_uuid())
19    }
20}
21
22impl Display for UUID {
23    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
24        write!(f, "{}", self.0)
25    }
26}