sl4f_lib/location/
types.rs1use fidl_fuchsia_location_position::{Position, PositionExtras};
6use serde::{Serialize, Serializer};
7
8#[derive(Serialize)]
9#[serde(remote = "Position")]
10struct PositionDef {
11 pub latitude: f64,
12 pub longitude: f64,
13 #[serde(with = "PositionExtrasDef")]
14 pub extras: PositionExtras,
15}
16
17#[derive(Serialize)]
18struct PositionExtrasDef {
19 pub accuracy_meters: Option<f64>,
20 pub altitude_meters: Option<f64>,
21}
22
23impl PositionExtrasDef {
24 fn serialize<S: Serializer>(
27 &PositionExtras { accuracy_meters, altitude_meters, .. }: &PositionExtras,
28 serializer: S,
29 ) -> Result<S::Ok, S::Error> {
30 Self { accuracy_meters, altitude_meters }.serialize(serializer)
31 }
32}
33
34#[derive(Serialize)]
35pub struct PositionSerializer(#[serde(with = "PositionDef")] pub Position);