sampler_config/
common.rs
1use serde::{Deserialize, Serialize};
6use std::fmt;
7use std::ops::Deref;
8
9#[derive(Copy, Clone, Debug, Default, Deserialize, Hash, PartialEq, Eq, Serialize)]
10pub struct ProjectId(pub u32);
11
12impl fmt::Display for ProjectId {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 write!(f, "{}", self.0)
15 }
16}
17
18impl Deref for ProjectId {
19 type Target = u32;
20
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25
26#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Hash, Eq, Serialize)]
27pub struct CustomerId(pub u32);
28
29impl fmt::Display for CustomerId {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 write!(f, "{}", self.0)
32 }
33}
34
35impl Default for CustomerId {
36 fn default() -> Self {
37 CustomerId(1)
38 }
39}
40
41impl Deref for CustomerId {
42 type Target = u32;
43
44 fn deref(&self) -> &Self::Target {
45 &self.0
46 }
47}
48
49#[derive(Copy, Clone, Debug, Deserialize, Hash, PartialEq, Eq, Serialize)]
50pub struct MetricId(pub u32);
51
52impl fmt::Display for MetricId {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 write!(f, "{}", self.0)
55 }
56}
57
58impl Deref for MetricId {
59 type Target = u32;
60
61 fn deref(&self) -> &Self::Target {
62 &self.0
63 }
64}
65
66#[derive(Copy, Clone, Debug, Deserialize, Hash, PartialEq, Eq, Serialize)]
67pub struct EventCode(pub u32);
68
69impl fmt::Display for EventCode {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 write!(f, "{}", self.0)
72 }
73}
74
75impl Deref for EventCode {
76 type Target = u32;
77
78 fn deref(&self) -> &Self::Target {
79 &self.0
80 }
81}
82
83#[derive(Deserialize, Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize)]
85pub enum MetricType {
86 Occurrence,
89
90 Integer,
92
93 IntHistogram,
95
96 String,
98}