use std::marker::PhantomData;
use euroscope_sys::EsHandle;
use crate::{Position, utils::cstr};
#[derive(Clone, Copy)]
pub struct PositionPredictions<'cb> {
raw: EsHandle,
_marker: PhantomData<&'cb ()>,
}
impl PositionPredictions<'_> {
pub(crate) fn from_raw(raw: EsHandle) -> Self {
Self {
raw,
_marker: PhantomData,
}
}
#[expect(dead_code)]
pub(crate) fn as_ptr(&self) -> EsHandle {
self.raw
}
pub fn points_number(&self) -> i32 {
unsafe { euroscope_sys::es_positionpredictions_points_number(self.raw) }
}
pub fn position(&self, index: i32) -> Position {
let mut lat = 0.0_f64;
let mut lon = 0.0_f64;
unsafe {
euroscope_sys::es_positionpredictions_position(
self.raw,
index,
&raw mut lat,
&raw mut lon,
);
}
Position::new(lat, lon)
}
pub fn altitude(&self, index: i32) -> i32 {
unsafe { euroscope_sys::es_positionpredictions_altitude(self.raw, index) }
}
pub fn controller_id(&self, index: i32) -> &str {
unsafe {
cstr(euroscope_sys::es_positionpredictions_controller_id(
self.raw, index,
))
}
}
}