sustenet_shared/
network.rs

1pub enum Protocols {
2    TCP,
3    UDP,
4}
5
6/// Enum to represent all possible events that can be sent to the event loop.
7pub enum Event {
8    Connection(u32),
9    Disconnection(u32),
10    ReceivedData(u32, Vec<u8>),
11}
12
13#[derive(Eq)]
14pub struct ClusterInfo {
15    pub id: u32,
16    pub name: String,
17    pub ip: String,
18    pub port: u16,
19    pub max_connections: u32,
20}
21
22impl Ord for ClusterInfo {
23    fn cmp(&self, other: &Self) -> std::cmp::Ordering {
24        // Define how to compare two ClusterInfo instances
25        // For example, if ClusterInfo has a field `id` of type i32:
26        self.id.cmp(&other.id)
27    }
28}
29
30impl PartialOrd for ClusterInfo {
31    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
32        Some(self.cmp(other))
33    }
34}
35
36impl PartialEq for ClusterInfo {
37    fn eq(&self, other: &Self) -> bool {
38        // Define when two ClusterInfo instances are equal
39        // For example, if ClusterInfo has a field `id` of type i32:
40        self.id == other.id
41    }
42}