mm1_proto_system/
wait.rs

1use std::fmt;
2
3use mm1_address::address::Address;
4use mm1_proto::message;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7#[message(base_path = ::mm1_proto)]
8pub struct WatchRef(u64);
9
10#[derive(Debug)]
11#[message(base_path = ::mm1_proto)]
12pub struct Watch {
13    pub peer: Address,
14}
15
16#[derive(Debug)]
17#[message(base_path = ::mm1_proto)]
18pub struct Unwatch {
19    pub watch_ref: WatchRef,
20}
21
22#[derive(Debug)]
23#[message(base_path = ::mm1_proto)]
24pub struct Down {
25    pub peer:        Address,
26    pub watch_ref:   WatchRef,
27    pub normal_exit: bool,
28}
29
30impl WatchRef {
31    pub const MAX: Self = WatchRef::from_u64(u64::MAX);
32    pub const MIN: Self = WatchRef::from_u64(u64::MIN);
33
34    pub const fn from_u64(v: u64) -> Self {
35        Self(v)
36    }
37
38    pub const fn into_u64(self) -> u64 {
39        self.0
40    }
41}
42
43impl fmt::Display for WatchRef {
44    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45        fmt::Debug::fmt(self, f)
46    }
47}