server_node/server/peer/
message.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
//! # Internal Server-to-Server Protocol
//!
//! This module contains traits for establishing connections and sending and receiving messages to server peers.
//!
//! The server communication style is message passing with multicast.
//!
//! Jump to [`Message`] for the server-to-server message definition.

use crate::{
    dhcp::{Ipv4Range, Lease},
    server::peer,
};
use protocol::{RecvCbor, SendCbor};
use serde::{Deserialize, Serialize};
use std::net::TcpStream;

/// # A server-to-server message
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub enum Message {
    Join(peer::Id),
    JoinAck(peer::Id),
    Heartbeat,
    Election,
    Okay,
    Coordinator { majority: bool },
    Lease(Lease),
    LeaseTable(Vec<Lease>),
    SetPool(Ipv4Range),
}

impl RecvCbor<Message> for TcpStream {}
impl SendCbor<Message> for TcpStream {}