Skip to main content

zenoh_stats/
lib.rs

1use std::fmt;
2
3mod family;
4mod histogram;
5mod keys;
6mod labels;
7mod link;
8mod registry;
9mod stats;
10mod transport;
11
12pub use crate::{
13    keys::{StatsKeyCache, StatsKeys, StatsKeysTree},
14    labels::{LocalityLabel, MessageLabel, ReasonLabel, ResourceLabel, SpaceLabel},
15    link::LinkStats,
16    registry::StatsRegistry,
17    transport::{DropStats, TransportStats},
18    StatsDirection::*,
19};
20
21#[derive(Debug, Clone, Copy)]
22pub enum StatsDirection {
23    Tx,
24    Rx,
25}
26
27impl StatsDirection {
28    const NUM: usize = 2;
29
30    fn from_index(index: usize) -> Self {
31        match index {
32            i if i == Tx as usize => Tx,
33            i if i == Rx as usize => Rx,
34            _ => unreachable!(),
35        }
36    }
37}
38
39impl fmt::Display for StatsDirection {
40    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41        match self {
42            Self::Tx => write!(f, "tx"),
43            Self::Rx => write!(f, "rx"),
44        }
45    }
46}