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

Generated by: LCOV version 2.1-beta