datex_core/utils/
uuid.rs

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