Skip to main content

twapi_v2/fields/
place_fields.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashSet;
3
4#[derive(Serialize, Deserialize, Debug, Eq, Hash, PartialEq, Clone, Default)]
5pub enum PlaceFields {
6    #[serde(rename = "contained_within")]
7    #[default]
8    ContainedWithin,
9    #[serde(rename = "country")]
10    Country,
11    #[serde(rename = "country_code")]
12    CountryCode,
13    #[serde(rename = "full_name")]
14    FullName,
15    #[serde(rename = "geo")]
16    Geo,
17    #[serde(rename = "id")]
18    Id,
19    #[serde(rename = "name")]
20    Name,
21    #[serde(rename = "place_type")]
22    PlaceType,
23}
24
25impl PlaceFields {
26    pub fn all() -> HashSet<Self> {
27        let mut result = HashSet::new();
28        result.insert(Self::ContainedWithin);
29        result.insert(Self::Country);
30        result.insert(Self::CountryCode);
31        result.insert(Self::FullName);
32        result.insert(Self::Geo);
33        result.insert(Self::Id);
34        result.insert(Self::Name);
35        result.insert(Self::PlaceType);
36        result
37    }
38}
39
40impl std::fmt::Display for PlaceFields {
41    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
42        match self {
43            Self::ContainedWithin => write!(f, "contained_within"),
44            Self::Country => write!(f, "country"),
45            Self::CountryCode => write!(f, "country_code"),
46            Self::FullName => write!(f, "full_name"),
47            Self::Geo => write!(f, "geo"),
48            Self::Id => write!(f, "id"),
49            Self::Name => write!(f, "name"),
50            Self::PlaceType => write!(f, "place_type"),
51        }
52    }
53}