Skip to main content

google_maps/types/
place_type.rs

1//! Contains the `PlaceType` enum and its associated traits. It specifies the
2//! types or categories of a place. For example, a returned place could be a
3//! "country" (as in a nation) or it could be a "shopping mall."
4
5use crate::error::Error as GoogleMapsError;
6use phf::phf_map;
7use serde::{Deserialize, Deserializer, Serialize, Serializer};
8
9// -----------------------------------------------------------------------------
10
11/// This specifies the types or categories of a place. For example, a returned
12/// location could be a "country" (as in a nation) or it could be a "shopping
13/// mall." Also, a requested place could be a "locality" (a city) or a
14/// "`street_address`" This type helps define the data that is being returned or
15/// sought. See [Place
16/// Types](https://developers.google.com/places/web-service/supported_types)
17/// for more information.
18#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
19#[repr(u8)]
20#[non_exhaustive]
21pub enum PlaceType {
22    // [Table 1: Place types](https://developers.google.com/places/web-service/supported_types#table1)
23    // The types that are supported for place searches, and can be returned with Place details results, and as part of autocomplete place predictions.
24    Accounting = 0,
25    /// Indicates an airport.
26    Airport = 1,
27    AmusementPark = 2,
28    Aquarium = 3,
29    ArtGallery = 4,
30    Atm = 5,
31    Bakery = 6,
32    Bank = 7,
33    Bar = 8,
34    BeautySalon = 9,
35    BicycleStore = 10,
36    BookStore = 11,
37    BowlingAlley = 12,
38    BusStation = 13,
39    Cafe = 14,
40    Campground = 15,
41    CarDealer = 16,
42    CarRental = 17,
43    CarRepair = 18,
44    CarWash = 19,
45    Casino = 20,
46    Cemetery = 21,
47    Church = 22,
48    CityHall = 23,
49    ClothingStore = 24,
50    ConvenienceStore = 25,
51    Courthouse = 26,
52    Dentist = 27,
53    DepartmentStore = 28,
54    Doctor = 29,
55    DrugStore = 30,
56    Electrician = 31,
57    ElectronicsStore = 32,
58    Embassy = 33,
59    FireStation = 34,
60    Florist = 35,
61    FuneralHome = 36,
62    FurnitureStore = 37,
63    GasStation = 38,
64    GroceryOrSupermarket = 39,
65    Gym = 40,
66    HairCare = 41,
67    HardwareStore = 42,
68    HinduTemple = 43,
69    HomeGoodsStore = 44,
70    Hospital = 45,
71    InsuranceAgency = 46,
72    JewelryStore = 47,
73    Laundry = 48,
74    Lawyer = 49,
75    Library = 50,
76    LightRailStation = 51,
77    LiquorStore = 52,
78    LocalGovernmentOffice = 53,
79    Locksmith = 54,
80    Lodging = 55,
81    MealDelivery = 56,
82    MealTakeaway = 57,
83    Mosque = 58,
84    MovieRental = 59,
85    MovieTheater = 60,
86    MovingCompany = 61,
87    Museum = 62,
88    NightClub = 63,
89    Painter = 64,
90    /// Indicates a named park.
91    Park = 65,
92    Parking = 66,
93    PetStore = 67,
94    Pharmacy = 68,
95    Physiotherapist = 69,
96    Plumber = 70,
97    PlusCode = 71,
98    Police = 72,
99    PostOffice = 73,
100    PrimarySchool = 74,
101    RealEstateAgency = 75,
102    Restaurant = 76,
103    RoofingContractor = 77,
104    RvPark = 78,
105    School = 79,
106    SecondarySchool = 80,
107    ShoeStore = 81,
108    ShoppingMall = 82,
109    Spa = 83,
110    Stadium = 84,
111    Storage = 85,
112    Store = 86,
113    SubwayStation = 87,
114    Supermarket = 88,
115    Synagogue = 89,
116    TaxiStand = 90,
117    TouristAttraction = 91,
118    TrainStation = 92,
119    TransitStation = 93,
120    TravelAgency = 94,
121    University = 95,
122    VeterinaryCare = 96,
123    Zoo = 97,
124    // [Table 2: Additional types returned by the Places service](https://developers.google.com/places/web-service/supported_types#table2)
125    // Additional types that can be returned with Place details results, and as part of autocomplete place predictions.
126    // Note: The types below are *not supported* in the `type` filter of a place search.
127    /// Indicates a first-order civil entity below the country level. Within the
128    /// United States, these administrative levels are states. Not all nations
129    /// exhibit these administrative levels. In most cases,
130    /// `AdministrativeAreaLevel1` short names will closely match ISO 3166-2
131    /// subdivisions and other widely circulated lists; however this is not
132    /// guaranteed as our geocoding results are based on a variety of signals
133    /// and location data.
134    AdministrativeAreaLevel1 = 98,
135    /// Indicates a second-order civil entity below the country level. Within
136    /// the United States, these administrative levels are counties. Not all
137    /// nations exhibit these administrative levels.
138    AdministrativeAreaLevel2 = 99,
139    /// Indicates a third-order civil entity below the country level. This type
140    /// indicates a minor civil division. Not all nations exhibit these
141    /// administrative levels.
142    AdministrativeAreaLevel3 = 100,
143    /// Indicates a fourth-order civil entity below the country level. This type
144    /// indicates a minor civil division. Not all nations exhibit these
145    /// administrative levels.
146    AdministrativeAreaLevel4 = 101,
147    /// Indicates a fifth-order civil entity below the country level. This type
148    /// indicates a minor civil division. Not all nations exhibit these
149    /// administrative levels.
150    AdministrativeAreaLevel5 = 102,
151    Archipelago = 103,
152    /// Indicates a commonly-used alternative name for the entity.
153    ColloquialArea = 104,
154    Continent = 105,
155    /// Indicates the national political entity, and is typically the highest
156    /// order type returned by the Geocoder.
157    Country = 106,
158    Establishment = 107,
159    Finance = 108,
160    Floor = 109,
161    Food = 110,
162    GeneralContractor = 111,
163    Geocode = 112,
164    Health = 113,
165    /// Indicates a major intersection, usually of two major roads.
166    Intersection = 114,
167    /// Indicates an incorporated city or town political entity.
168    #[default]
169    Locality = 115,
170    /// Indicates a prominent natural feature.
171    NaturalFeature = 116,
172    /// Indicates a named neighborhood.
173    Neighborhood = 117,
174    PlaceOfWorship = 118,
175    /// Indicates a named point of interest. Typically, these "POI"s are
176    /// prominent local entities that don't easily fit in another category, such
177    /// as "Empire State Building" or "Eiffel Tower".
178    PointOfInterest = 119,
179    /// Indicates a political entity. Usually, this type indicates a polygon of
180    /// some civil administration.
181    Political = 120,
182    PostBox = 121,
183    /// Indicates a postal code as used to address postal mail within the
184    /// country.
185    PostalCode = 122,
186    PostalCodePrefix = 123,
187    PostalCodeSuffix = 124,
188    PostalTown = 125,
189    /// Indicates a named location, usually a building or collection of
190    /// buildings with a common name.
191    Premise = 126,
192    Room = 127,
193    /// Indicates a named route (such as "US 101").
194    Route = 128,
195    /// Indicates a precise street address.
196    StreetAddress = 129,
197    StreetNumber = 130,
198    /// Indicates a first-order civil entity below a locality. For some
199    /// locations may receive one of the additional types: `SublocalityLevel1`
200    /// to `SublocalityLevel5`. Each sublocality level is a civil entity. Larger
201    /// numbers indicate a smaller geographic area.
202    Sublocality = 131,
203    SublocalityLevel1 = 132,
204    SublocalityLevel2 = 133,
205    SublocalityLevel3 = 134,
206    SublocalityLevel4 = 135,
207    SublocalityLevel5 = 136,
208    /// Indicates a first-order entity below a named location, usually a
209    /// singular building within a collection of buildings with a common name.
210    Subpremise = 137,
211    TownSquare = 138,
212    // [Table 3: Types supported in place autocomplete requests](https://developers.google.com/places/web-service/supported_types#table3)
213    // Types you can use in place autocomplete requests.
214    // #[serde(alias = "geocode")]
215    // Geocode,
216    Address = 139,
217    // #[serde(alias = "establishment")]
218    // Establishment,
219    Regions = 140,
220    Cities = 141,
221    Landmark = 142,
222    /// If the place type is not recognized by
223    /// [serde](https://crates.io/crates/serde) when reading data from
224    /// Google it will be assigned to this `Other` variant.
225    ///
226    /// As new types are added to Google Maps, they must also be added to this
227    /// crate. However, in the meantime, the `Other` catch-all variant allows
228    /// `serde` to read data from Google without producing an error until the
229    /// new variant added to this `enum`.
230    Other = 143,
231} // enum
232
233// -----------------------------------------------------------------------------
234
235impl<'de> Deserialize<'de> for PlaceType {
236    /// Manual implementation of `Deserialize` for `serde`. This will take
237    /// advantage of the `phf`-powered `TryFrom` implementation for this type.
238    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
239        let string = String::deserialize(deserializer)?;
240        match Self::try_from(string.as_str()) {
241            Ok(variant) => Ok(variant),
242            Err(error) => Err(serde::de::Error::custom(error.to_string())),
243        } // match
244    } // fn
245} // impl
246
247// -----------------------------------------------------------------------------
248
249impl Serialize for PlaceType {
250    /// Manual implementation of `Serialize` for `serde`.
251    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
252    where
253        S: Serializer,
254    {
255        serializer.serialize_str(std::convert::Into::<&str>::into(self))
256    } // fn
257} // impl
258
259// -----------------------------------------------------------------------------
260
261impl std::convert::From<&Self> for PlaceType {
262    /// Converts a borrowed `&PlaceType` enum into an owned `PlaceType` enum
263    /// by copying it.
264    fn from(place_type: &Self) -> Self {
265        *place_type
266    } // fn
267} // impl
268
269// -----------------------------------------------------------------------------
270
271impl std::convert::From<&PlaceType> for &str {
272    /// Converts a `PlaceType` enum to a `String` that contains a [place
273    /// type](https://developers.google.com/places/web-service/supported_types)
274    /// code.
275    fn from(place_type: &PlaceType) -> Self {
276        match place_type {
277            PlaceType::Accounting => "accounting",
278            PlaceType::Airport => "airport",
279            PlaceType::AmusementPark => "amusement_park",
280            PlaceType::Aquarium => "aquarium",
281            PlaceType::ArtGallery => "art_gallery",
282            PlaceType::Atm => "atm",
283            PlaceType::Bakery => "bakery",
284            PlaceType::Bank => "bank",
285            PlaceType::Bar => "bar",
286            PlaceType::BeautySalon => "beauty_salon",
287            PlaceType::BicycleStore => "bicycle_store",
288            PlaceType::BookStore => "book_store",
289            PlaceType::BowlingAlley => "bowling_alley",
290            PlaceType::BusStation => "bus_station",
291            PlaceType::Cafe => "cafe",
292            PlaceType::Campground => "campground",
293            PlaceType::CarDealer => "car_dealer",
294            PlaceType::CarRental => "car_rental",
295            PlaceType::CarRepair => "car_repair",
296            PlaceType::CarWash => "car_wash",
297            PlaceType::Casino => "casino",
298            PlaceType::Cemetery => "cemetery",
299            PlaceType::Church => "church",
300            PlaceType::CityHall => "city_hall",
301            PlaceType::ClothingStore => "clothing_store",
302            PlaceType::ConvenienceStore => "convenience_store",
303            PlaceType::Courthouse => "courthouse",
304            PlaceType::Dentist => "dentist",
305            PlaceType::DepartmentStore => "department_store",
306            PlaceType::Doctor => "doctor",
307            PlaceType::DrugStore => "drugstore",
308            PlaceType::Electrician => "electrician",
309            PlaceType::ElectronicsStore => "electronics_store",
310            PlaceType::Embassy => "embassy",
311            PlaceType::FireStation => "fire_station",
312            PlaceType::Florist => "florist",
313            PlaceType::FuneralHome => "funeral_home",
314            PlaceType::FurnitureStore => "furniture_store",
315            PlaceType::GasStation => "gas_station",
316            PlaceType::GroceryOrSupermarket => "grocery_or_supermarket",
317            PlaceType::Gym => "gym",
318            PlaceType::HairCare => "hair_care",
319            PlaceType::HardwareStore => "hardware_store",
320            PlaceType::HinduTemple => "hindu_temple",
321            PlaceType::HomeGoodsStore => "home_goods_store",
322            PlaceType::Hospital => "hospital",
323            PlaceType::InsuranceAgency => "insurance_agency",
324            PlaceType::JewelryStore => "jewelry_store",
325            PlaceType::Laundry => "laundry",
326            PlaceType::Lawyer => "lawyer",
327            PlaceType::Library => "library",
328            PlaceType::LightRailStation => "light_rail_station",
329            PlaceType::LiquorStore => "liquor_store",
330            PlaceType::LocalGovernmentOffice => "local_government_office",
331            PlaceType::Locksmith => "locksmith",
332            PlaceType::Lodging => "lodging",
333            PlaceType::MealDelivery => "meal_delivery",
334            PlaceType::MealTakeaway => "meal_takeaway",
335            PlaceType::Mosque => "mosque",
336            PlaceType::MovieRental => "movie_rental",
337            PlaceType::MovieTheater => "movie_theater",
338            PlaceType::MovingCompany => "moving_company",
339            PlaceType::Museum => "museum",
340            PlaceType::NightClub => "night_club",
341            PlaceType::Painter => "painter",
342            PlaceType::Park => "park",
343            PlaceType::Parking => "parking",
344            PlaceType::PetStore => "pet_store",
345            PlaceType::Pharmacy => "pharmacy",
346            PlaceType::Physiotherapist => "physiotherapist",
347            PlaceType::Plumber => "plumber",
348            PlaceType::PlusCode => "plus_code",
349            PlaceType::Police => "police",
350            PlaceType::PostOffice => "post_office",
351            PlaceType::PrimarySchool => "primary_school",
352            PlaceType::RealEstateAgency => "real_estate_agency",
353            PlaceType::Restaurant => "restaurant",
354            PlaceType::RoofingContractor => "roofing_contractor",
355            PlaceType::RvPark => "rv_park",
356            PlaceType::School => "school",
357            PlaceType::SecondarySchool => "secondary_school",
358            PlaceType::ShoeStore => "shoe_store",
359            PlaceType::ShoppingMall => "shopping_mall",
360            PlaceType::Spa => "spa",
361            PlaceType::Stadium => "stadium",
362            PlaceType::Storage => "storage",
363            PlaceType::Store => "store",
364            PlaceType::SubwayStation => "subway_station",
365            PlaceType::Supermarket => "supermarket",
366            PlaceType::Synagogue => "synagogue",
367            PlaceType::TaxiStand => "taxi_stand",
368            PlaceType::TouristAttraction => "tourist_attraction",
369            PlaceType::TrainStation => "train_station",
370            PlaceType::TransitStation => "transit_station",
371            PlaceType::TravelAgency => "travel_agency",
372            PlaceType::University => "university",
373            PlaceType::VeterinaryCare => "veterinary_care",
374            PlaceType::Zoo => "zoo",
375            PlaceType::AdministrativeAreaLevel1 => "administrative_area_level_1",
376            PlaceType::AdministrativeAreaLevel2 => "administrative_area_level_2",
377            PlaceType::AdministrativeAreaLevel3 => "administrative_area_level_3",
378            PlaceType::AdministrativeAreaLevel4 => "administrative_area_level_4",
379            PlaceType::AdministrativeAreaLevel5 => "administrative_area_level_5",
380            PlaceType::Archipelago => "archipelago",
381            PlaceType::ColloquialArea => "colloquial_area",
382            PlaceType::Continent => "continent",
383            PlaceType::Country => "country",
384            PlaceType::Establishment => "establishment",
385            PlaceType::Finance => "finance",
386            PlaceType::Floor => "floor",
387            PlaceType::Food => "food",
388            PlaceType::GeneralContractor => "general_contractor",
389            PlaceType::Geocode => "geocode",
390            PlaceType::Health => "health",
391            PlaceType::Intersection => "intersection",
392            PlaceType::Locality => "locality",
393            PlaceType::NaturalFeature => "natural_feature",
394            PlaceType::Neighborhood => "neighborhood",
395            PlaceType::PlaceOfWorship => "place_of_worship",
396            PlaceType::PointOfInterest => "point_of_interest",
397            PlaceType::Political => "political",
398            PlaceType::PostBox => "post_box",
399            PlaceType::PostalCode => "postal_code",
400            PlaceType::PostalCodePrefix => "postal_code_prefix",
401            PlaceType::PostalCodeSuffix => "postal_code_suffix",
402            PlaceType::PostalTown => "postal_town",
403            PlaceType::Premise => "premise",
404            PlaceType::Room => "room",
405            PlaceType::Route => "route",
406            PlaceType::StreetAddress => "street_address",
407            PlaceType::StreetNumber => "street_number",
408            PlaceType::Sublocality => "sublocality",
409            PlaceType::SublocalityLevel1 => "sublocality_level_1",
410            PlaceType::SublocalityLevel2 => "sublocality_level_2",
411            PlaceType::SublocalityLevel3 => "sublocality_level_3",
412            PlaceType::SublocalityLevel4 => "sublocality_level_4",
413            PlaceType::SublocalityLevel5 => "sublocality_level_5",
414            PlaceType::Subpremise => "subpremise",
415            PlaceType::TownSquare => "town_square",
416            PlaceType::Address => "address",
417            PlaceType::Regions => "regions",
418            PlaceType::Cities => "cities",
419            PlaceType::Landmark => "landmark",
420            PlaceType::Other => "other",
421        } // match
422    } // fn
423} // impl
424
425// -----------------------------------------------------------------------------
426
427impl std::fmt::Display for PlaceType {
428    /// Converts a `PlaceType` enum to a `String` that contains a [place
429    /// type](https://developers.google.com/places/web-service/supported_types)
430    /// code.
431    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
432        write!(f, "{}", std::convert::Into::<&str>::into(self))
433    } // fmt
434} // impl
435
436// -----------------------------------------------------------------------------
437
438impl std::convert::From<&PlaceType> for String {
439    /// Converts a `PlaceType` enum to a `String` that contains a [place
440    /// type](https://developers.google.com/places/web-service/supported_types)
441    /// code.
442    fn from(place_type: &PlaceType) -> Self {
443        std::convert::Into::<&str>::into(place_type).to_string()
444    } // fn
445} // impl
446
447// -----------------------------------------------------------------------------
448
449static PLACE_TYPES_BY_CODE: phf::Map<&'static str, PlaceType> = phf_map! {
450    "accounting" => PlaceType::Accounting,
451    "airport" => PlaceType::Airport,
452    "amusement_park" => PlaceType::AmusementPark,
453    "aquarium" => PlaceType::Aquarium,
454    "art_gallery" => PlaceType::ArtGallery,
455    "atm" => PlaceType::Atm,
456    "bakery" => PlaceType::Bakery,
457    "bank" => PlaceType::Bank,
458    "bar" => PlaceType::Bar,
459    "beauty_salon" => PlaceType::BeautySalon,
460    "bicycle_store" => PlaceType::BicycleStore,
461    "book_store" => PlaceType::BookStore,
462    "bowling_alley" => PlaceType::BowlingAlley,
463    "bus_station" => PlaceType::BusStation,
464    "cafe" => PlaceType::Cafe,
465    "campground" => PlaceType::Campground,
466    "car_dealer" => PlaceType::CarDealer,
467    "car_rental" => PlaceType::CarRental,
468    "car_repair" => PlaceType::CarRepair,
469    "car_wash" => PlaceType::CarWash,
470    "casino" => PlaceType::Casino,
471    "cemetery" => PlaceType::Cemetery,
472    "church" => PlaceType::Church,
473    "city_hall" => PlaceType::CityHall,
474    "clothing_store" => PlaceType::ClothingStore,
475    "convenience_store" => PlaceType::ConvenienceStore,
476    "courthouse" => PlaceType::Courthouse,
477    "dentist" => PlaceType::Dentist,
478    "department_store" => PlaceType::DepartmentStore,
479    "doctor" => PlaceType::Doctor,
480    "drugstore" => PlaceType::DrugStore,
481    "electrician" => PlaceType::Electrician,
482    "electronics_store" => PlaceType::ElectronicsStore,
483    "embassy" => PlaceType::Embassy,
484    "fire_station" => PlaceType::FireStation,
485    "florist" => PlaceType::Florist,
486    "funeral_home" => PlaceType::FuneralHome,
487    "furniture_store" => PlaceType::FurnitureStore,
488    "gas_station" => PlaceType::GasStation,
489    "grocery_or_supermarket" => PlaceType::GroceryOrSupermarket,
490    "gym" => PlaceType::Gym,
491    "hair_care" => PlaceType::HairCare,
492    "hardware_store" => PlaceType::HardwareStore,
493    "hindu_temple" => PlaceType::HinduTemple,
494    "home_goods_store" => PlaceType::HomeGoodsStore,
495    "hospital" => PlaceType::Hospital,
496    "insurance_agency" => PlaceType::InsuranceAgency,
497    "jewelry_store" => PlaceType::JewelryStore,
498    "laundry" => PlaceType::Laundry,
499    "lawyer" => PlaceType::Lawyer,
500    "library" => PlaceType::Library,
501    "light_rail_station" => PlaceType::LightRailStation,
502    "liquor_store" => PlaceType::LiquorStore,
503    "local_government_office" => PlaceType::LocalGovernmentOffice,
504    "locksmith" => PlaceType::Locksmith,
505    "lodging" => PlaceType::Lodging,
506    "meal_delivery" => PlaceType::MealDelivery,
507    "meal_takeaway" => PlaceType::MealTakeaway,
508    "mosque" => PlaceType::Mosque,
509    "movie_rental" => PlaceType::MovieRental,
510    "movie_theater" => PlaceType::MovieTheater,
511    "moving_company" => PlaceType::MovingCompany,
512    "museum" => PlaceType::Museum,
513    "night_club" => PlaceType::NightClub,
514    "painter" => PlaceType::Painter,
515    "park" => PlaceType::Park,
516    "parking" => PlaceType::Parking,
517    "pet_store" => PlaceType::PetStore,
518    "pharmacy" => PlaceType::Pharmacy,
519    "physiotherapist" => PlaceType::Physiotherapist,
520    "plumber" => PlaceType::Plumber,
521    "plus_code" => PlaceType::PlusCode,
522    "police" => PlaceType::Police,
523    "post_office" => PlaceType::PostOffice,
524    "primary_school" => PlaceType::PrimarySchool,
525    "real_estate_agency" => PlaceType::RealEstateAgency,
526    "restaurant" => PlaceType::Restaurant,
527    "roofing_contractor" => PlaceType::RoofingContractor,
528    "rv_park" => PlaceType::RvPark,
529    "school" => PlaceType::School,
530    "secondary_school" => PlaceType::SecondarySchool,
531    "shoe_store" => PlaceType::ShoeStore,
532    "shopping_mall" => PlaceType::ShoppingMall,
533    "spa" => PlaceType::Spa,
534    "stadium" => PlaceType::Stadium,
535    "storage" => PlaceType::Storage,
536    "store" => PlaceType::Store,
537    "subway_station" => PlaceType::SubwayStation,
538    "supermarket" => PlaceType::Supermarket,
539    "synagogue" => PlaceType::Synagogue,
540    "taxi_stand" => PlaceType::TaxiStand,
541    "tourist_attraction" => PlaceType::TouristAttraction,
542    "train_station" => PlaceType::TrainStation,
543    "transit_station" => PlaceType::TransitStation,
544    "travel_agency" => PlaceType::TravelAgency,
545    "university" => PlaceType::University,
546    "veterinary_care" => PlaceType::VeterinaryCare,
547    "zoo" => PlaceType::Zoo,
548    "administrative_area_level_1" => PlaceType::AdministrativeAreaLevel1,
549    "administrative_area_level_2" => PlaceType::AdministrativeAreaLevel2,
550    "administrative_area_level_3" => PlaceType::AdministrativeAreaLevel3,
551    "administrative_area_level_4" => PlaceType::AdministrativeAreaLevel4,
552    "administrative_area_level_5" => PlaceType::AdministrativeAreaLevel5,
553    "archipelago" => PlaceType::Archipelago,
554    "colloquial_area" => PlaceType::ColloquialArea,
555    "continent" => PlaceType::Continent,
556    "country" => PlaceType::Country,
557    "establishment" => PlaceType::Establishment,
558    "finance" => PlaceType::Finance,
559    "floor" => PlaceType::Floor,
560    "food" => PlaceType::Food,
561    "general_contractor" => PlaceType::GeneralContractor,
562    "geocode" => PlaceType::Geocode,
563    "health" => PlaceType::Health,
564    "intersection" => PlaceType::Intersection,
565    "locality" => PlaceType::Locality,
566    "natural_feature" => PlaceType::NaturalFeature,
567    "neighborhood" => PlaceType::Neighborhood,
568    "place_of_worship" => PlaceType::PlaceOfWorship,
569    "point_of_interest" => PlaceType::PointOfInterest,
570    "political" => PlaceType::Political,
571    "post_box" => PlaceType::PostBox,
572    "postal_code" => PlaceType::PostalCode,
573    "postal_code_prefix" => PlaceType::PostalCodePrefix,
574    "postal_code_suffix" => PlaceType::PostalCodeSuffix,
575    "postal_town" => PlaceType::PostalTown,
576    "premise" => PlaceType::Premise,
577    "room" => PlaceType::Room,
578    "route" => PlaceType::Route,
579    "street_address" => PlaceType::StreetAddress,
580    "street_number" => PlaceType::StreetNumber,
581    "sublocality" => PlaceType::Sublocality,
582    "sublocality_level_1" => PlaceType::SublocalityLevel1,
583    "sublocality_level_2" => PlaceType::SublocalityLevel2,
584    "sublocality_level_3" => PlaceType::SublocalityLevel3,
585    "sublocality_level_4" => PlaceType::SublocalityLevel4,
586    "sublocality_level_5" => PlaceType::SublocalityLevel5,
587    "subpremise" => PlaceType::Subpremise,
588    "town_square" => PlaceType::TownSquare,
589    "address" => PlaceType::Address,
590    "regions" => PlaceType::Regions,
591    "cities" => PlaceType::Cities,
592    "landmark" => PlaceType::Landmark,
593    "other" => PlaceType::Other,
594};
595
596// -----------------------------------------------------------------------------
597
598impl std::convert::TryFrom<&str> for PlaceType {
599    // Error definitions are contained in the `google_maps\src\error.rs` module.
600    type Error = GoogleMapsError;
601    /// Gets a `PlaceType` enum from a `String` that contains a supported [place
602    /// type](https://developers.google.com/places/web-service/supported_types)
603    /// code.
604    fn try_from(place_type_code: &str) -> Result<Self, Self::Error> {
605        Ok(PLACE_TYPES_BY_CODE
606            .get(place_type_code)
607            .copied()
608            .unwrap_or(Self::Other))
609    } // fn
610} // impl
611
612// -----------------------------------------------------------------------------
613
614impl std::str::FromStr for PlaceType {
615    // Error definitions are contained in the `google_maps\src\error.rs` module.
616    type Err = GoogleMapsError;
617    /// Gets a `PlaceType` enum from a `String` that contains a supported [place
618    /// type](https://developers.google.com/places/web-service/supported_types)
619    /// code.
620    fn from_str(place_type_code: &str) -> Result<Self, Self::Err> {
621        Ok(PLACE_TYPES_BY_CODE
622            .get(place_type_code)
623            .copied()
624            .unwrap_or(Self::Other))
625    } // fn
626} // impl
627
628// -----------------------------------------------------------------------------
629
630impl PlaceType {
631    /// Formats a `PlaceType` enum into a string that is presentable to the end
632    /// user.
633    #[must_use]
634    pub const fn display(&self) -> &str {
635        match self {
636            Self::Accounting => "Accounting",
637            Self::Airport => "Airport",
638            Self::AmusementPark => "Amusement Park",
639            Self::Aquarium => "Aquarium",
640            Self::ArtGallery => "Art Gallery",
641            Self::Atm => "ATM",
642            Self::Bakery => "Bakery",
643            Self::Bank => "Bank",
644            Self::Bar => "Bar",
645            Self::BeautySalon => "Beauty Salon",
646            Self::BicycleStore => "Bicycle Store",
647            Self::BookStore => "Book Store",
648            Self::BowlingAlley => "Bowling Alley",
649            Self::BusStation => "Bus Station",
650            Self::Cafe => "Café",
651            Self::Campground => "Campground",
652            Self::CarDealer => "Car Dealer",
653            Self::CarRental => "Car Rental",
654            Self::CarRepair => "Car Repair",
655            Self::CarWash => "Car Wash",
656            Self::Casino => "Casino",
657            Self::Cemetery => "Cemetery",
658            Self::Church => "Church",
659            Self::CityHall => "City Hall",
660            Self::ClothingStore => "Clothing Store",
661            Self::ConvenienceStore => "Convenience Store",
662            Self::Courthouse => "Courthouse",
663            Self::Dentist => "Dentist",
664            Self::DepartmentStore => "Department Store",
665            Self::Doctor => "Doctor",
666            Self::DrugStore => "Drug Store",
667            Self::Electrician => "Electrician",
668            Self::ElectronicsStore => "Electronics Store",
669            Self::Embassy => "Embassy",
670            Self::FireStation => "Fire Station",
671            Self::Florist => "Florist",
672            Self::FuneralHome => "Funeral Home",
673            Self::FurnitureStore => "Furniture Store",
674            Self::GasStation => "Gas Station",
675            Self::GroceryOrSupermarket => "Grocery or Supermarket",
676            Self::Gym => "Gym",
677            Self::HairCare => "Hair Care",
678            Self::HardwareStore => "Hardware Store",
679            Self::HinduTemple => "Hindu Temple",
680            Self::HomeGoodsStore => "Home Goods Store",
681            Self::Hospital => "Hospital",
682            Self::InsuranceAgency => "Insurance Agency",
683            Self::JewelryStore => "Jewelry Store",
684            Self::Laundry => "Laundry",
685            Self::Lawyer => "Lawyer",
686            Self::Library => "Library",
687            Self::LightRailStation => "Light Rail Station",
688            Self::LiquorStore => "Liquor Store",
689            Self::LocalGovernmentOffice => "Local Government Office",
690            Self::Locksmith => "Locksmith",
691            Self::Lodging => "Lodging",
692            Self::MealDelivery => "Meal Delivery",
693            Self::MealTakeaway => "Meal Takeaway",
694            Self::Mosque => "Mosque",
695            Self::MovieRental => "Movie Rental",
696            Self::MovieTheater => "Movie Theater",
697            Self::MovingCompany => "Moving Company",
698            Self::Museum => "Museum",
699            Self::NightClub => "Night Club",
700            Self::Painter => "Painter",
701            Self::Park => "Park",
702            Self::Parking => "Parking",
703            Self::PetStore => "Pet Store",
704            Self::Pharmacy => "Pharmacy",
705            Self::Physiotherapist => "Physiotherapist",
706            Self::Plumber => "Plumber",
707            Self::PlusCode => "Plus Code",
708            Self::Police => "Police",
709            Self::PostOffice => "Post Office",
710            Self::PrimarySchool => "Primary School",
711            Self::RealEstateAgency => "Real Estate Agency",
712            Self::Restaurant => "Restaurant",
713            Self::RoofingContractor => "Roofing Contractor",
714            Self::RvPark => "RV Park",
715            Self::School => "School",
716            Self::SecondarySchool => "Secondary School",
717            Self::ShoeStore => "Shoe Store",
718            Self::ShoppingMall => "Shopping Mall",
719            Self::Spa => "Spa",
720            Self::Stadium => "Stadium",
721            Self::Storage => "Storage",
722            Self::Store => "Store",
723            Self::SubwayStation => "Subway Station",
724            Self::Supermarket => "Supermarket",
725            Self::Synagogue => "Synagogue",
726            Self::TaxiStand => "Taxi Stand",
727            Self::TouristAttraction => "Tourist Attraction",
728            Self::TrainStation => "Train Station",
729            Self::TransitStation => "Transit Station",
730            Self::TravelAgency => "Travel Agency",
731            Self::University => "University",
732            Self::VeterinaryCare => "Veterinary Care",
733            Self::Zoo => "Zoo",
734            Self::AdministrativeAreaLevel1 => "Administrative Area Level 1",
735            Self::AdministrativeAreaLevel2 => "Administrative Area Level 2",
736            Self::AdministrativeAreaLevel3 => "Administrative Area Level 3",
737            Self::AdministrativeAreaLevel4 => "Administrative Area Level 4",
738            Self::AdministrativeAreaLevel5 => "Administrative Area Level 5",
739            Self::Archipelago => "Archipelago",
740            Self::ColloquialArea => "Colloquial Area",
741            Self::Continent => "Continent",
742            Self::Country => "Country",
743            Self::Establishment => "Establishment",
744            Self::Finance => "Finance",
745            Self::Floor => "Floor",
746            Self::Food => "Food",
747            Self::GeneralContractor => "General Contractor",
748            Self::Geocode => "Geocode",
749            Self::Health => "Health",
750            Self::Intersection => "Intersection",
751            Self::Locality => "Locality",
752            Self::NaturalFeature => "Natural Feature",
753            Self::Neighborhood => "Neighborhood",
754            Self::PlaceOfWorship => "Place of Worship",
755            Self::PointOfInterest => "Point of Interest",
756            Self::Political => "Political",
757            Self::PostBox => "Post Box",
758            Self::PostalCode => "Postal Code",
759            Self::PostalCodePrefix => "Postal Code Prefix",
760            Self::PostalCodeSuffix => "Postal Code Suffix",
761            Self::PostalTown => "Postal Town",
762            Self::Premise => "Premise",
763            Self::Room => "Room",
764            Self::Route => "Route",
765            Self::StreetAddress => "Street Address",
766            Self::StreetNumber => "Street Number",
767            Self::Sublocality => "Sublocality",
768            Self::SublocalityLevel1 => "Sublocality Level 1",
769            Self::SublocalityLevel2 => "Sublocality Level 2",
770            Self::SublocalityLevel3 => "Sublocality Level 3",
771            Self::SublocalityLevel4 => "Sublocality Level 4",
772            Self::SublocalityLevel5 => "Sublocality Level 5",
773            Self::Subpremise => "Subpremise",
774            Self::TownSquare => "Town Square",
775            Self::Address => "Address",
776            Self::Regions => "Regions",
777            Self::Cities => "Cities",
778            Self::Landmark => "Landmark",
779            Self::Other => "Other",
780        } // match
781    } // fn
782} // impl
783
784// -----------------------------------------------------------------------------
785
786impl PlaceType {
787    /// A helper function that converts a `Vec<PlaceType>` (i.e. an array of
788    /// `PlaceType` enum) to a `String` that contains a comma-delimited list of
789    /// [place
790    /// types](https://developers.google.com/places/web-service/supported_types)
791    /// codes.
792    pub fn vec_to_csv(place_types: &[Self]) -> String {
793        place_types
794            .iter()
795            .map(String::from)
796            .collect::<Vec<String>>()
797            .join(",")
798    } // fn
799} // impl