quantized_density_fields/
id.rs

1use std::fmt;
2use uuid::Uuid;
3
4/// Universal Identifier (uuidv4).
5#[derive(PartialEq, Eq, Hash, Copy, Clone, PartialOrd, Ord)]
6pub struct ID(Uuid);
7
8impl ID {
9    /// Creates new identifier.
10    #[inline]
11    pub fn new() -> Self {
12        Self::default()
13    }
14
15    /// Gets underlying UUID object.
16    #[inline]
17    pub fn uuid(&self) -> Uuid {
18        self.0
19    }
20}
21
22impl Default for ID {
23    #[inline]
24    fn default() -> Self {
25        ID(Uuid::new_v4())
26    }
27}
28
29impl fmt::Debug for ID {
30    #[inline]
31    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
32        write!(f, "{}", self.to_string())
33    }
34}
35
36impl ToString for ID {
37    #[inline]
38    fn to_string(&self) -> String {
39        format!("ID({})", self.0)
40    }
41}