geocoder/
structs.rs

1use serde::Deserialize;
2
3/// LatLng is a struct that represents a latitude and longitude pair.
4#[derive(Debug, Clone, Copy, Deserialize)]
5pub struct LatLng {
6    pub lat: f64,
7    pub lng: f64,
8}
9
10/// Bounds is a struct that represents NorthEast and SouthWest LatLng pairs.
11#[derive(Debug, Clone, Copy, Deserialize)]
12pub struct Bounds {
13    pub northeast: LatLng,
14    pub southwest: LatLng,
15}
16
17/// Geometry is a struct that represents a location and a viewport.
18#[derive(Debug, Clone, Deserialize)]
19pub struct Geometry {
20    pub bounds: Option<Bounds>,
21    pub location: LatLng,
22    #[serde(rename = "location_type")]
23    pub location_type: String,
24    pub viewport: Bounds,
25}
26
27/// AddressComponent is a struct that represents a component of an address.
28#[derive(Debug, Clone, Deserialize)]
29pub struct Address {
30    #[serde(rename = "long_name")]
31    pub long_name: String,
32    #[serde(rename = "short_name")]
33    pub short_name: String,
34    pub types: Vec<String>,
35}
36
37/// Result is a struct that represents a geocoding result.
38#[derive(Debug, Clone, Deserialize)]
39pub struct Result {
40    #[serde(rename = "address_components")]
41    pub address_components: Vec<Address>,
42    #[serde(rename = "formatted_address")]
43    pub formatted_address: String,
44    pub geometry: Geometry,
45    #[serde(rename = "place_id")]
46    pub place_id: String,
47    pub types: Vec<String>,
48}
49
50/// GeocodeResponse is a struct that represents a response from the geocoding API.
51#[derive(Debug, Clone, Deserialize)]
52pub struct GeocodeResponse {
53    pub results: Vec<Result>,
54    pub status: String,
55    #[serde(rename = "error_message")]
56    pub error_message: Option<String>,
57}