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
use std::fmt::{Display, Debug};

#[derive(PartialEq, Eq, Hash, Clone)]
pub struct NodeId {
    port: i64,
    addr: String,
}

impl NodeId {
    pub fn new(port: i64, addr: String) -> Self {
        Self { port, addr }
    }
}

impl Display for NodeId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}{}", self.addr, self.port)
    }
}

impl Debug for NodeId{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self)
    }
}