LCOV - code coverage report
Current view: top level - libs/desim/src - proto.rs (source / functions) Coverage Total Hit
Test: 53437f7e869ac68c86c7d3e4c20964c0156f158c.info Lines: 55.6 % 9 5
Test Date: 2024-09-20 16:14:12 Functions: 100.0 % 1 1

            Line data    Source code
       1              : use std::fmt::Debug;
       2              : 
       3              : use bytes::Bytes;
       4              : use utils::lsn::Lsn;
       5              : 
       6              : use crate::{network::TCP, world::NodeId};
       7              : 
       8              : /// Internal node events.
       9              : #[derive(Debug)]
      10              : pub enum NodeEvent {
      11              :     Accept(TCP),
      12              :     Internal(AnyMessage),
      13              : }
      14              : 
      15              : /// Events that are coming from a network socket.
      16              : #[derive(Clone, Debug)]
      17              : pub enum NetEvent {
      18              :     Message(AnyMessage),
      19              :     Closed,
      20              : }
      21              : 
      22              : /// Custom events generated throughout the simulation. Can be used by the test to verify the correctness.
      23              : #[derive(Debug)]
      24              : pub struct SimEvent {
      25              :     pub time: u64,
      26              :     pub node: NodeId,
      27              :     pub data: String,
      28              : }
      29              : 
      30              : /// Umbrella type for all possible flavours of messages. These events can be sent over network
      31              : /// or to an internal node events channel.
      32              : #[derive(Clone)]
      33              : pub enum AnyMessage {
      34              :     /// Not used, empty placeholder.
      35              :     None,
      36              :     /// Used internally for notifying node about new incoming connection.
      37              :     InternalConnect,
      38              :     Just32(u32),
      39              :     ReplCell(ReplCell),
      40              :     Bytes(Bytes),
      41              :     LSN(u64),
      42              : }
      43              : 
      44              : impl Debug for AnyMessage {
      45          425 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      46          425 :         match self {
      47            0 :             AnyMessage::None => write!(f, "None"),
      48            0 :             AnyMessage::InternalConnect => write!(f, "InternalConnect"),
      49            0 :             AnyMessage::Just32(v) => write!(f, "Just32({})", v),
      50          381 :             AnyMessage::ReplCell(v) => write!(f, "ReplCell({:?})", v),
      51           44 :             AnyMessage::Bytes(v) => write!(f, "Bytes({})", hex::encode(v)),
      52            0 :             AnyMessage::LSN(v) => write!(f, "LSN({})", Lsn(*v)),
      53              :         }
      54          425 :     }
      55              : }
      56              : 
      57              : /// Used in reliable_copy_test.rs
      58              : #[derive(Clone, Debug)]
      59              : pub struct ReplCell {
      60              :     pub value: u32,
      61              :     pub client_id: u32,
      62              :     pub seqno: u32,
      63              : }
        

Generated by: LCOV version 2.1-beta