mm1_proto_system/
wait.rs

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
use std::fmt;

use mm1_address::address::Address;
use mm1_proto::Traversable;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct WatchRef(u64);

#[derive(Debug, Traversable)]
pub struct Watch {
    pub peer: Address,
}

#[derive(Debug, Traversable)]
pub struct Unwatch {
    pub watch_ref: WatchRef,
}

#[derive(Debug, Traversable)]
pub struct Down {
    pub peer:        Address,
    pub watch_ref:   WatchRef,
    pub normal_exit: bool,
}

impl WatchRef {
    pub const MAX: Self = WatchRef::from_u64(u64::MAX);
    pub const MIN: Self = WatchRef::from_u64(u64::MIN);

    pub const fn from_u64(v: u64) -> Self {
        Self(v)
    }

    pub const fn into_u64(self) -> u64 {
        self.0
    }
}

impl fmt::Display for WatchRef {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Debug::fmt(self, f)
    }
}