Skip to main content

CaptchaProvider

Trait CaptchaProvider 

Source
pub trait CaptchaProvider: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn detected_kind(&self) -> DetectedCaptcha;
    fn captcha_type(&self) -> CaptchaType;
    fn recommended_solver_methods(&self) -> &'static [SolveMethod];
    fn detector(&self) -> &dyn Detector;

    // Provided method
    fn recommended_solver_names(&self) -> &'static [&'static str] { ... }
}
Expand description

One captcha vendor / type, fully described.

New captchas implement this trait alongside Detector in a single file under src/detect/. The bundled metadata lets the orchestrator dispatch detection AND make an informed first guess about which solver to try first — without depending on the [PatternStore] having seen the domain before.

recommended_solver_methods is a HINT, not a constraint: the solver chain may override the order based on per-domain learned success rates from the pattern store.

Required Methods§

Source

fn name(&self) -> &'static str

Stable identifier — same value as Detector::name by convention so logs and reports correlate.

Source

fn detected_kind(&self) -> DetectedCaptcha

The DetectedCaptcha variant this provider produces.

Source

fn captcha_type(&self) -> CaptchaType

The CaptchaType used by the solver chain to look up per-type behaviour.

Source

fn recommended_solver_methods(&self) -> &'static [SolveMethod]

Solver methods, ordered by recommended preference for this captcha. The chain consults this for cold-start routing; once the pattern store has data for the domain, learned ordering takes priority.

Method-based routing collides when multiple solvers share a SolveMethod (Math, Pow, Slider, Behavioral all return BehavioralBypass) — the chain has to fall back to the first solver whose supports() returns true, which is fragile. New code SHOULD implement Self::recommended_solver_names instead; that path is name-based and avoids collisions. This method stays for backwards compatibility and is the fallback when recommended_solver_names() returns empty.

Source

fn detector(&self) -> &dyn Detector

Borrow the page-side detector this provider is bound to.

Provided Methods§

Source

fn recommended_solver_names(&self) -> &'static [&'static str]

Solver name()s, ordered by recommended preference. When non-empty, the chain prefers this list over Self::recommended_solver_methods — every name is matched against solver.name() exactly. Empty default means the chain falls back to method-based routing (the older path).

Use this for vendors with dedicated solvers (TurnstileInteractiveSolver, DataDomeSolver, etc.) so the vendor’s specific solver wins over the generic one even when both implement the same SolveMethod.

Implementors§