• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geo-engine / geoengine / 23040029767

13 Mar 2026 07:01AM UTC coverage: 88.139%. First build
23040029767

Pull #1130

github

web-flow
Merge 57754d45e into ca0d5a3ca
Pull Request #1130: feat: add histogram and statistics plot operators to openapi.json

399 of 436 new or added lines in 9 files covered. (91.51%)

113112 of 128333 relevant lines covered (88.14%)

504631.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.7
/services/src/api/model/processing_graphs/macros.rs
1
/// Generates a serializable and OpenAPI compatible string token
2
///
3
/// # Examples
4
///
5
/// `string_token!(Foo)` generates `Foo` that is serialized as `"Foo"`
6
///
7
/// `string_token!(Bar "bar")` generates `Bar` that is serialized as `"bar"`
8
///
9
#[macro_export]
10
macro_rules! string_token {
11
    ($struct:ident) => {
12
        string_token!($struct, stringify!($struct));
13
    };
14

15
    ($struct:ident, $string:expr) => {
16
        #[derive(Debug, Copy, Clone, PartialEq, Eq, Default, utoipa::ToSchema)]
17
        pub struct $struct;
18

19
        impl serde::Serialize for $struct {
20
            fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
4✔
21
            where
4✔
22
                S: serde::Serializer,
4✔
23
            {
24
                serializer.serialize_str($string)
4✔
25
            }
4✔
26
        }
27

28
        impl<'de> serde::Deserialize<'de> for $struct {
29
            fn deserialize<D>(
4✔
30
                deserializer: D,
4✔
31
            ) -> Result<Self, <D as serde::Deserializer<'de>>::Error>
4✔
32
            where
4✔
33
                D: serde::Deserializer<'de>,
4✔
34
            {
35
                struct DeserializeVisitor;
36

37
                impl<'a> serde::de::Visitor<'a> for DeserializeVisitor {
38
                    type Value = $struct;
39

NEW
40
                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
×
NEW
41
                        formatter.write_str($string)
×
NEW
42
                    }
×
43

44
                    fn visit_borrowed_str<E>(self, v: &'a str) -> Result<Self::Value, E>
4✔
45
                    where
4✔
46
                        E: serde::de::Error,
4✔
47
                    {
48
                        use serde::de::Unexpected;
49

50
                        if v == $string {
4✔
51
                            Ok($struct)
4✔
52
                        } else {
NEW
53
                            Err(E::invalid_value(Unexpected::Str(v), &self))
×
54
                        }
55
                    }
4✔
56

57
                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
2✔
58
                    where
2✔
59
                        E: serde::de::Error,
2✔
60
                    {
61
                        self.visit_borrowed_str(v)
2✔
62
                    }
2✔
63
                }
64

65
                deserializer.deserialize_str(DeserializeVisitor)
4✔
66
            }
4✔
67
        }
68
    };
69
}
70

71
#[cfg(test)]
72
mod tests {
73

74
    #[test]
75
    fn serialize() {
1✔
76
        string_token!(Foo);
77
        string_token!(Bar, "bar");
78

79
        assert_eq!(
1✔
80
            serde_json::to_string(&Foo).unwrap(),
1✔
81
            serde_json::json! {"Foo"}.to_string()
1✔
82
        );
83
        assert_eq!(
1✔
84
            serde_json::to_string(&Bar).unwrap(),
1✔
85
            serde_json::json! {"bar"}.to_string()
1✔
86
        );
87

88
        serde_json::from_str::<Foo>(&serde_json::json! {"Foo"}.to_string()).unwrap();
1✔
89
        serde_json::from_str::<Bar>(&serde_json::json! {"bar"}.to_string()).unwrap();
1✔
90
    }
1✔
91

92
    #[test]
93
    fn binary() {
1✔
94
        string_token!(Foo);
95
        string_token!(Bar, "bar");
96

97
        let serialized_bytes: Vec<u8> = serde_json::to_string(&Foo).unwrap().into_bytes();
1✔
98
        let _: Foo = serde_json::from_reader(serialized_bytes.as_slice()).unwrap();
1✔
99

100
        let serialized_bytes: Vec<u8> = serde_json::to_string(&Bar).unwrap().into_bytes();
1✔
101
        let _: Bar = serde_json::from_reader(serialized_bytes.as_slice()).unwrap();
1✔
102
    }
1✔
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc