serde_firestore_value/typ/
lat_lng.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::google::r#type::LatLng as GoogleApiProtoLatLng;

/// LatLng
///
/// `geoPointValue` inner type.
///
/// <https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/LatLng>
/// <https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/ArrayValue#Value>
///
/// # Examples
///
/// ```rust
/// # fn test_lat_lng() -> Result<(), serde_firestore_value::Error> {
/// #     use serde_firestore_value::google::{firestore::v1::{value::ValueType, Value}, self};
/// #     use serde_firestore_value::{from_value, to_value, LatLng};
/// let o = LatLng {
///     latitude: 1_f64,
///     longitude: 2_f64,
/// };
/// let v = Value {
///     value_type: Some(ValueType::GeoPointValue(
///         google::r#type::LatLng {
///             latitude: 1_f64,
///             longitude: 2_f64,
///         },
///     )),
/// };
/// let s = to_value(&o)?;
/// let d = from_value::<'_, LatLng>(&s)?;
/// assert_eq!(s, v);
/// assert_eq!(d, o);
/// #     Ok(())
/// # }
#[derive(Clone, Copy, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(rename = "$__serde-firestore-value_private_lat_lng")]
pub struct LatLng {
    /// latitude
    pub latitude: f64,
    /// longitude
    pub longitude: f64,
}

impl LatLng {
    pub(crate) const NAME: &'static str = "$__serde-firestore-value_private_lat_lng";
}

impl From<GoogleApiProtoLatLng> for LatLng {
    fn from(
        GoogleApiProtoLatLng {
            latitude,
            longitude,
        }: GoogleApiProtoLatLng,
    ) -> Self {
        Self {
            latitude,
            longitude,
        }
    }
}

impl From<LatLng> for GoogleApiProtoLatLng {
    fn from(
        LatLng {
            latitude,
            longitude,
        }: LatLng,
    ) -> Self {
        Self {
            latitude,
            longitude,
        }
    }
}