use crate::{Error, FixedField, Numeric};
pub struct ArcDistance<'a>(Numeric<'a, 4>);
impl<'a> ArcDistance<'a> {
pub fn dist(&self) -> Result<f32, Error> {
self.0.as_u32().map(|dist| dist as f32 / 10.0)
}
}
impl<'a> FixedField<'a> for ArcDistance<'a> {
const LENGTH: usize = 4;
fn from_bytes(bytes: &'a [u8]) -> Result<Self, Error> {
Ok(Self(Numeric::from_bytes(bytes)?))
}
}
pub struct ArcBearing<'a>(Numeric<'a, 4>);
impl<'a> ArcBearing<'a> {
pub fn deg(&self) -> Result<f32, Error> {
self.0.as_u32().map(|dist| dist as f32 / 10.0)
}
}
impl<'a> FixedField<'a> for ArcBearing<'a> {
const LENGTH: usize = 4;
fn from_bytes(bytes: &'a [u8]) -> Result<Self, Error> {
Ok(Self(Numeric::from_bytes(bytes)?))
}
}