1use std::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub struct ProcessId(pub u32);
11
12impl ProcessId {
13 pub fn new(id: u32) -> Self {
15 ProcessId(id)
16 }
17
18 pub fn as_u32(&self) -> u32 {
20 self.0
21 }
22}
23
24impl From<u32> for ProcessId {
25 fn from(id: u32) -> Self {
26 ProcessId(id)
27 }
28}
29
30impl From<ProcessId> for u32 {
31 fn from(id: ProcessId) -> Self {
32 id.0
33 }
34}
35
36impl fmt::Display for ProcessId {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 write!(f, "{}", self.0)
39 }
40}
41impl PartialEq<u32> for ProcessId {
42 fn eq(&self, other: &u32) -> bool {
43 self.0 == *other
44 }
45}
46
47impl PartialEq<ProcessId> for u32 {
48 fn eq(&self, other: &ProcessId) -> bool {
49 *self == other.0
50 }
51}
52
53#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
58pub struct ThreadId(pub u32);
59
60impl ThreadId {
61 pub fn new(id: u32) -> Self {
63 ThreadId(id)
64 }
65
66 pub fn as_u32(&self) -> u32 {
68 self.0
69 }
70}
71
72impl From<u32> for ThreadId {
73 fn from(id: u32) -> Self {
74 ThreadId(id)
75 }
76}
77
78impl From<ThreadId> for u32 {
79 fn from(id: ThreadId) -> Self {
80 id.0
81 }
82}
83
84impl fmt::Display for ThreadId {
85 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
86 write!(f, "{}", self.0)
87 }
88}
89
90impl PartialEq<u32> for ThreadId {
91 fn eq(&self, other: &u32) -> bool {
92 self.0 == *other
93 }
94}
95
96impl PartialEq<ThreadId> for u32 {
97 fn eq(&self, other: &ThreadId) -> bool {
98 *self == other.0
99 }
100}