Trait PatternDetector
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§
fn check(
&self,
state: &State,
event: Option<&SessionEvent>,
now: Instant,
) -> bool
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).
fn reset(&self)
fn reset(&self)
Reset the detector’s internal state (counters, timestamps, etc.).
Provided Methods§
fn needs_timer(&self) -> bool
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.