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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use alloc::string::{String, ToString};
use burn_common::id::IdGenerator;

#[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub struct ParamId {
    value: String,
}

impl From<&str> for ParamId {
    fn from(val: &str) -> Self {
        Self {
            value: val.to_string(),
        }
    }
}

impl From<String> for ParamId {
    fn from(value: String) -> Self {
        Self { value }
    }
}

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

impl ParamId {
    pub fn new() -> Self {
        Self {
            value: IdGenerator::generate(),
        }
    }
    pub fn into_string(self) -> String {
        self.value
    }
}

impl core::fmt::Display for ParamId {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        f.write_str(self.value.as_str())
    }
}