sightloom_analysis/
config.rs1use crate::{AnalyticsError, AnchorPolicy};
4use sightloom_core::ClassId;
5
6#[derive(Clone, Copy, Debug, PartialEq)]
8pub struct ZoneAnalyticsConfig {
9 pub anchor: AnchorPolicy,
11 pub enter_hysteresis: u32,
13 pub exit_hysteresis: u32,
15 pub missed_frame_tolerance: u32,
17 pub class_filter: Option<ClassId>,
19 pub dwell_start_debounce_ns: i64,
21}
22
23impl Default for ZoneAnalyticsConfig {
24 fn default() -> Self {
25 Self {
26 anchor: AnchorPolicy::Center,
27 enter_hysteresis: 1,
28 exit_hysteresis: 1,
29 missed_frame_tolerance: 0,
30 class_filter: None,
31 dwell_start_debounce_ns: 0,
32 }
33 }
34}
35
36impl ZoneAnalyticsConfig {
37 pub fn validate(self) -> Result<Self, AnalyticsError> {
43 if self.enter_hysteresis == 0 || self.exit_hysteresis == 0 {
44 return Err(AnalyticsError::InvalidConfig);
45 }
46 if self.dwell_start_debounce_ns < 0 {
47 return Err(AnalyticsError::InvalidConfig);
48 }
49 Ok(self)
50 }
51}