serde_firestore_value/typ/
lat_lng.rs

1use crate::google::r#type::LatLng as GoogleApiProtoLatLng;
2
3/// LatLng
4///
5/// `geoPointValue` inner type.
6///
7/// <https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/LatLng>
8/// <https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/ArrayValue#Value>
9///
10/// # Examples
11///
12/// ```rust
13/// # fn test_lat_lng() -> Result<(), serde_firestore_value::Error> {
14/// #     use serde_firestore_value::google::{firestore::v1::{value::ValueType, Value}, self};
15/// #     use serde_firestore_value::{from_value, to_value, LatLng};
16/// let o = LatLng {
17///     latitude: 1_f64,
18///     longitude: 2_f64,
19/// };
20/// let v = Value {
21///     value_type: Some(ValueType::GeoPointValue(
22///         google::r#type::LatLng {
23///             latitude: 1_f64,
24///             longitude: 2_f64,
25///         },
26///     )),
27/// };
28/// let s = to_value(&o)?;
29/// let d = from_value::<'_, LatLng>(&s)?;
30/// assert_eq!(s, v);
31/// assert_eq!(d, o);
32/// #     Ok(())
33/// # }
34#[derive(Clone, Copy, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
35#[serde(rename = "$__serde-firestore-value_private_lat_lng")]
36pub struct LatLng {
37    /// latitude
38    pub latitude: f64,
39    /// longitude
40    pub longitude: f64,
41}
42
43impl LatLng {
44    pub(crate) const NAME: &'static str = "$__serde-firestore-value_private_lat_lng";
45}
46
47impl From<GoogleApiProtoLatLng> for LatLng {
48    fn from(
49        GoogleApiProtoLatLng {
50            latitude,
51            longitude,
52        }: GoogleApiProtoLatLng,
53    ) -> Self {
54        Self {
55            latitude,
56            longitude,
57        }
58    }
59}
60
61impl From<LatLng> for GoogleApiProtoLatLng {
62    fn from(
63        LatLng {
64            latitude,
65            longitude,
66        }: LatLng,
67    ) -> Self {
68        Self {
69            latitude,
70            longitude,
71        }
72    }
73}