av_stream_info_rust/
lat_long.rs1use crate::DecodeError;
2use std::convert::TryFrom;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize, Clone)]
18pub struct LatLong {
19 pub lat: f64,
21 pub long: f64,
23}
24
25impl TryFrom<String> for LatLong {
26 type Error = DecodeError;
27
28 fn try_from(
29 lat_long_str: String,
30 ) -> std::result::Result<Self, <Self as TryFrom<String>>::Error> {
31 let mut iter = lat_long_str.splitn(2, ",");
32 Ok(LatLong {
33 lat: iter
34 .next()
35 .ok_or(DecodeError::LatMissing)?
36 .parse()
37 .or(Err(DecodeError::NumberParseError))?,
38 long: iter
39 .next()
40 .ok_or(DecodeError::LongMissing)?
41 .parse()
42 .or(Err(DecodeError::NumberParseError))?,
43 })
44 }
45}