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

geo-engine / geoengine / 23057588730

13 Mar 2026 03:20PM UTC coverage: 88.251%. First build
23057588730

Pull #1130

github

web-flow
Merge 96f28eebb 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%)

113255 of 128333 relevant lines covered (88.25%)

504640.77 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
/// This is a unit struct which serializes as a string that only has one possible value.
3
///
4
/// # Examples
5
///
6
/// `string_token!(Foo)` generates `Foo` that is serialized as `"Foo"`
7
///
8
/// `string_token!(Bar "bar")` generates `Bar` that is serialized as `"bar"`
9
///
10
#[macro_export]
11
macro_rules! string_token {
12
    ($struct:ident) => {
13
        string_token!($struct, stringify!($struct));
14
    };
15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

101
        let serialized_bytes: Vec<u8> = serde_json::to_string(&Bar).unwrap().into_bytes();
1✔
102
        let _: Bar = serde_json::from_reader(serialized_bytes.as_slice()).unwrap();
1✔
103
    }
1✔
104
}
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