pub struct WatcherBuilder<'s> { /* private fields */ }Expand description
Configures one watcher. Created via Session::watch; consumed by subscribe.
Implementations§
Source§impl<'s> WatcherBuilder<'s>
impl<'s> WatcherBuilder<'s>
pub fn region(self, region: Region) -> Self
pub fn rate(self, rate: Rate) -> Self
Sourcepub fn frame_diff(self, enabled: bool) -> Self
pub fn frame_diff(self, enabled: bool) -> Self
The implicit pixels-changed gate. On by default; disable for detectors that must run even when the region is static.
Sourcepub fn gate(self, gate: impl Detector) -> Self
pub fn gate(self, gate: impl Detector) -> Self
Add a gate: a boolean detector that must report Bool(true) for the
main detector to run this tick. Gates run in registration order.
pub fn detector(self, detector: impl Detector) -> Self
Sourcepub fn on_change(self) -> Self
pub fn on_change(self) -> Self
Default mode: emit Changed when the detector output transitions.
Sourcepub fn on_every_match(self) -> Self
pub fn on_every_match(self) -> Self
Emit Matched on every tick where the detector matches.
Sourcepub fn on_threshold(
self,
predicate: impl Fn(f64) -> bool + Send + 'static,
) -> Self
pub fn on_threshold( self, predicate: impl Fn(f64) -> bool + Send + 'static, ) -> Self
Emit ThresholdCrossed when predicate(numeric_output) flips.
Sourcepub fn template(self, png_bytes: &[u8], threshold: f32) -> Self
pub fn template(self, png_bytes: &[u8], threshold: f32) -> Self
Watch for a PNG template. Emits TemplateAppeared when the best match
score reaches threshold (0.0..=1.0) and TemplateVanished when it
falls back below. Sets both the detector and the emission mode; like
all builder configuration, the last call wins.
Sourcepub fn ocr_text(self, engine: impl OcrEngine) -> Self
pub fn ocr_text(self, engine: impl OcrEngine) -> Self
OCR the region and emit text transitions (Changed with
DetectorOutput::Text/None). “Text appeared” is the
None -> Text(..) transition. Sets the detector only; the emission
mode stays chainable.
Sourcepub fn ocr(
self,
engine: impl OcrEngine,
pattern: impl Fn(&str) -> Option<f64> + Send + 'static,
) -> Self
pub fn ocr( self, engine: impl OcrEngine, pattern: impl Fn(&str) -> Option<f64> + Send + 'static, ) -> Self
OCR the region and parse a number out of the text (see
patterns::number). Pair with
.on_threshold(..) for HP-bar-style watchers.
Sourcepub fn subscribe(self) -> Result<EventStream>
pub fn subscribe(self) -> Result<EventStream>
Register the watcher and return its event stream.