1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Module contains Structs that describe all possible
//! responses of the [Prices](crate::api::price::PriceApi)
//! and [Station](crate::api::station::StationApi) api.

pub mod price;
pub mod station;

pub use price::PriceResponse;
pub use station::{AreaFuelResponse, AreaNearResponse, DetailsResponse};

/// Enum of all supported fuel types
#[derive(strum::EnumString, strum::Display, PartialEq, Debug, Eq, Clone, PartialOrd, Ord)]
pub enum Fuel {
    /// Super95 or E5 and serialized to `e5`
    #[strum(serialize = "e5")]
    E5,
    /// Super90 or E10 and serialized to `e10`
    #[strum(serialize = "e10")]
    E10,
    /// Diesel and serialized to `diesel`
    #[strum(serialize = "diesel")]
    Diesel,
}

/// Enum of supported sorting logic
#[derive(strum::EnumString, strum::Display, PartialEq, Debug, Eq, Clone, PartialOrd, Ord)]
pub enum Sort {
    /// Sort by price from lowest to highest price and
    /// will serialize to `price`
    #[strum(serialize = "price")]
    Price,
    /// Sort by distance from near to far and
    /// will serialize to `dist`
    #[strum(serialize = "dist")]
    Distance,
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn serialize_fuel_enum_e5() {
        assert_eq!(Fuel::E5.to_string(), "e5");
    }

    #[test]
    fn serialize_fuel_enum_e10() {
        assert_eq!(Fuel::E10.to_string(), "e10");
    }

    #[test]
    fn serialize_fuel_enum_diesel() {
        assert_eq!(Fuel::Diesel.to_string(), "diesel");
    }

    #[test]
    fn serialize_sort_enum_price() {
        assert_eq!(Sort::Price.to_string(), "price");
    }

    #[test]
    fn serialize_sort_enum_distance() {
        assert_eq!(Sort::Distance.to_string(), "dist");
    }
}