google_maps 3.9.5

An unofficial Google Maps Platform client library for the Rust programming language.
Documentation
//! Contains the `Api` enum and its associated traits. The `Api` enum is used to
//! specify a Google Maps Platform API when setting per-API request rate limits.

use serde::{Deserialize, Serialize};

// -----------------------------------------------------------------------------
//
/// `Api` is used to select an API to configure. For example, the Google Maps
/// Client can be set to have different request rates for `Directions` and
/// `Elevation` requests. This `enum` is used to select which Google Maps API
/// you would like to configure.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, Deserialize)]
#[repr(u8)]
pub enum Api {
    /// This variant is used to select settings that are observed for _all_
    /// APIs. These settings are observed in addition to the per-API settings.
    All = 0,
    Directions = 1,
    DistanceMatrix = 2,
    Elevation = 3,
    Geocoding = 4,
    TimeZone = 5,
    Roads = 6,
    AddressValidation = 7,
    // Places API (Legacy)
    Places = 8,
    // Places API (New)
    PlacesNew = 9,
    Autocomplete = 10,
    NearbySearch = 11,
    PlaceDetails = 12,
    PlacePhoto = 13,
    TextSearch = 14,
} // enum

// -----------------------------------------------------------------------------

impl std::convert::From<&Api> for String {
    /// Converts an `Api` enum to a `String` that contains an API name.
    fn from(api: &Api) -> Self {
        match api {
            Api::All => Self::from("All"),
            Api::Directions => Self::from("Directions"),
            Api::DistanceMatrix => Self::from("Distance Matrix"),
            Api::Elevation => Self::from("Elevation"),
            Api::Geocoding => Self::from("Geocoding"),
            Api::TimeZone => Self::from("Time Zone"),
            Api::Places => Self::from("Places"),
            Api::Roads => Self::from("Roads"),
            Api::AddressValidation => Self::from("Address Validation"),
            Api::PlacesNew => Self::from("Places (New)"),
            Api::Autocomplete => Self::from("Autocomplete"),
            Api::NearbySearch => Self::from("Nearby Search"),
            Api::PlaceDetails => Self::from("Place Details"),
            Api::PlacePhoto => Self::from("Place Photo"),
            Api::TextSearch => Self::from("Text Search"),
        } // match
    } // fn
} // impl

// -----------------------------------------------------------------------------

impl std::default::Default for Api {
    /// Returns a reasonable default variant for the `Api` enum.
    fn default() -> Self {
        Self::All
    } // fn
} // impl

// -----------------------------------------------------------------------------

impl std::fmt::Display for Api {
    /// Formats an `Api` enum into a string that is presentable to the end user.
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", String::from(self))
    } // fn
} // impl