nodedb_array/types/
domain.rs1use serde::{Deserialize, Serialize};
9
10#[derive(
12 Debug,
13 Clone,
14 PartialEq,
15 PartialOrd,
16 Serialize,
17 Deserialize,
18 zerompk::ToMessagePack,
19 zerompk::FromMessagePack,
20)]
21pub enum DomainBound {
22 Int64(i64),
23 Float64(f64),
24 TimestampMs(i64),
25 String(String),
27}
28
29impl Eq for DomainBound {}
30
31#[derive(
33 Debug,
34 Clone,
35 PartialEq,
36 Eq,
37 Serialize,
38 Deserialize,
39 zerompk::ToMessagePack,
40 zerompk::FromMessagePack,
41)]
42pub struct Domain {
43 pub lo: DomainBound,
44 pub hi: DomainBound,
45}
46
47impl Domain {
48 pub fn new(lo: DomainBound, hi: DomainBound) -> Self {
49 Self { lo, hi }
50 }
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn domain_round_trip_eq() {
59 let d = Domain::new(DomainBound::Int64(0), DomainBound::Int64(1_000_000));
60 let e = d.clone();
61 assert_eq!(d, e);
62 }
63}