detsys_ids_client/
identity.rs1#[derive(serde::Deserialize, serde::Serialize, Clone, Debug, PartialEq, Eq)]
2pub struct AnonymousDistinctId(String);
3
4impl AnonymousDistinctId {
5 pub fn new() -> AnonymousDistinctId {
6 AnonymousDistinctId(uuid::Uuid::now_v7().to_string())
7 }
8}
9
10impl Default for AnonymousDistinctId {
11 fn default() -> Self {
12 Self::new()
13 }
14}
15
16impl From<String> for AnonymousDistinctId {
17 fn from(value: String) -> Self {
18 Self(value)
19 }
20}
21
22impl std::fmt::Display for AnonymousDistinctId {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
24 write!(f, "{}", self.0)
25 }
26}
27
28#[derive(serde::Deserialize, serde::Serialize, Clone, Debug, PartialEq, Eq)]
29pub struct DistinctId(String);
30
31impl From<String> for DistinctId {
32 fn from(value: String) -> Self {
33 Self(value)
34 }
35}
36
37impl std::fmt::Display for DistinctId {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
39 write!(f, "{}", self.0)
40 }
41}
42
43#[derive(serde::Deserialize, serde::Serialize, Clone, Debug, PartialEq, Eq)]
44pub struct DeviceId(String);
45
46impl Default for DeviceId {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52impl DeviceId {
53 pub fn new() -> DeviceId {
54 DeviceId(format!("DIDS-DEV-{}", uuid::Uuid::now_v7()))
55 }
56}
57
58impl std::fmt::Display for DeviceId {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
60 write!(f, "{}", self.0)
61 }
62}
63
64impl From<String> for DeviceId {
65 fn from(value: String) -> Self {
66 Self(value)
67 }
68}