use std::collections::HashMap;
use serde::Deserialize;
use serde::Serialize;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PlaceResponse {
results: Vec<Place>
}
impl PlaceResponse {
#[inline]
pub fn results(&self) -> &[Place] {
&self.results
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Place {
#[serde(rename = "fsq_id")]
id: String,
name: String,
link: String,
location: Location,
categories: Vec<Category>,
chains: Vec<Chain>,
distance: u16,
geocodes: HashMap<String, GeoPoint>,
timezone: Option<String>
}
impl Place {
#[inline]
pub fn id(&self) -> &str {
&self.id
}
#[inline]
pub fn name(&self) -> &str {
&self.name
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Category {
id: u16,
name: String,
icon: Icon
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Icon {
prefix: String,
suffix: String
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Chain {
id: String,
name: String
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GeoPoint {
latitude: f32,
longitude: f32
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Location {
address: String,
census_block: String,
country: String,
#[serde(rename = "dma")]
designated_metro_area: Option<String>,
formatted_address: String,
locality: String,
postcode: String,
region: String
}