tracexec_core/event/
id.rs

1use std::ops::{Add, Sub};
2
3use nutype::nutype;
4
5#[nutype(derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize))]
6pub struct EventId(u64);
7
8impl Add<u64> for EventId {
9  type Output = Self;
10
11  fn add(self, rhs: u64) -> Self::Output {
12    Self::new(self.into_inner() + rhs)
13  }
14}
15
16impl Sub<u64> for EventId {
17  type Output = Self;
18
19  fn sub(self, rhs: u64) -> Self::Output {
20    Self::new(self.into_inner().saturating_sub(rhs))
21  }
22}
23
24impl EventId {
25  pub fn zero() -> Self {
26    Self::new(0)
27  }
28}