//! `MovementCandidate` — per `data_model.md §2 Perception entities`.

use serde::{Deserialize, Serialize};

use super::frame::BoundingBox;

#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct ResidualVelocity {
    /// Image-coordinate direction; unit vector.
    pub dx: f32,
    pub dy: f32,
    /// Magnitude in normalised image units per second.
    pub magnitude: f32,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum TelemetryQuality {
    Synced,
    Degraded,
    Unsynced,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ZoomBand {
    /// `Level 1` wide sweep.
    ZoomedOut,
    /// `Level 2` zoom-in hold.
    ZoomedIn,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MovementCandidate {
    pub frame_seq: u64,
    pub bbox_normalized: BoundingBox,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub residual_velocity_estimate: Option<ResidualVelocity>,
    pub telemetry_quality: TelemetryQuality,
    pub source_frame_ts_monotonic_ns: u64,
    pub source_zoom_band: ZoomBand,
}
