sl4f_lib/location/
types.rsuse fidl_fuchsia_location_position::{Position, PositionExtras};
use serde::{Serialize, Serializer};
#[derive(Serialize)]
#[serde(remote = "Position")]
struct PositionDef {
pub latitude: f64,
pub longitude: f64,
#[serde(with = "PositionExtrasDef")]
pub extras: PositionExtras,
}
#[derive(Serialize)]
struct PositionExtrasDef {
pub accuracy_meters: Option<f64>,
pub altitude_meters: Option<f64>,
}
impl PositionExtrasDef {
fn serialize<S: Serializer>(
&PositionExtras { accuracy_meters, altitude_meters, .. }: &PositionExtras,
serializer: S,
) -> Result<S::Ok, S::Error> {
Self { accuracy_meters, altitude_meters }.serialize(serializer)
}
}
#[derive(Serialize)]
pub struct PositionSerializer(#[serde(with = "PositionDef")] pub Position);