Skip to main content

WatcherBuilder

Struct WatcherBuilder 

Source
pub struct WatcherBuilder<'s> { /* private fields */ }
Expand description

Configures one watcher. Created via Session::watch; consumed by subscribe.

Implementations§

Source§

impl<'s> WatcherBuilder<'s>

Source

pub fn region(self, region: Region) -> Self

Source

pub fn rate(self, rate: Rate) -> Self

Source

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.

Source

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.

Source

pub fn detector(self, detector: impl Detector) -> Self

Source

pub fn on_change(self) -> Self

Default mode: emit Changed when the detector output transitions.

Source

pub fn on_every_match(self) -> Self

Emit Matched on every tick where the detector matches.

Source

pub fn on_threshold( self, predicate: impl Fn(f64) -> bool + Send + 'static, ) -> Self

Emit ThresholdCrossed when predicate(numeric_output) flips.

Source

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.

Source

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.

Source

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.

Source

pub fn subscribe(self) -> Result<EventStream>

Register the watcher and return its event stream.

Auto Trait Implementations§

§

impl<'s> !RefUnwindSafe for WatcherBuilder<'s>

§

impl<'s> !Sync for WatcherBuilder<'s>

§

impl<'s> !UnwindSafe for WatcherBuilder<'s>

§

impl<'s> Freeze for WatcherBuilder<'s>

§

impl<'s> Send for WatcherBuilder<'s>

§

impl<'s> Unpin for WatcherBuilder<'s>

§

impl<'s> UnsafeUnpin for WatcherBuilder<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more