PatternDetector

Trait PatternDetector 

Source
pub trait PatternDetector: Send + Sync {
    // Required methods
    fn check(
        &self,
        state: &State,
        event: Option<&SessionEvent>,
        now: Instant,
    ) -> bool;
    fn reset(&self);

    // Provided method
    fn needs_timer(&self) -> bool { ... }
}
Expand description

A detector that evaluates whether a temporal pattern has been triggered.

Implementations track internal state (timestamps, counters) to decide when a pattern fires. All interior mutability is handled via atomic operations or parking_lot locks so that &self suffices.

Required Methods§

Source

fn check( &self, state: &State, event: Option<&SessionEvent>, now: Instant, ) -> bool

Evaluate whether the pattern is currently triggered.

  • state: the current agent state snapshot.
  • event: the session event that prompted this check (if any).
  • now: the current instant (passed in for testability).
Source

fn reset(&self)

Reset the detector’s internal state (counters, timestamps, etc.).

Provided Methods§

Source

fn needs_timer(&self) -> bool

Whether this detector requires periodic timer checks.

Detectors that depend on elapsed time (e.g. SustainedDetector) should return true so the runtime can schedule a timer.

Implementors§