Skip to main content

appletheia_application/outbox/
outbox_relay_process_id.rs

1use std::{fmt, fmt::Display};
2
3#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
4pub struct OutboxRelayProcessId(u32);
5
6impl OutboxRelayProcessId {
7    pub fn new(value: u32) -> Self {
8        Self(value)
9    }
10
11    pub fn value(&self) -> u32 {
12        self.0
13    }
14}
15
16impl From<u32> for OutboxRelayProcessId {
17    fn from(value: u32) -> Self {
18        Self::new(value)
19    }
20}
21
22impl Display for OutboxRelayProcessId {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        write!(f, "{}", self.0)
25    }
26}
27
28#[cfg(test)]
29mod tests {
30    use super::*;
31
32    #[test]
33    fn value_round_trips() {
34        let pid = OutboxRelayProcessId::new(1234);
35        assert_eq!(pid.value(), 1234);
36
37        let from_u32 = OutboxRelayProcessId::from(5678);
38        assert_eq!(from_u32.value(), 5678);
39    }
40}