cloudscraper_rs/external_deps/captcha/
twocaptcha.rs

1use super::{CaptchaConfig, CaptchaError, CaptchaProvider, CaptchaResult, CaptchaTask};
2use async_trait::async_trait;
3
4/// Placeholder adapter for the TwoCaptcha service.
5#[derive(Debug, Clone)]
6pub struct TwoCaptchaProvider {
7    pub api_key: String,
8    pub config: CaptchaConfig,
9}
10
11impl TwoCaptchaProvider {
12    pub fn new(api_key: impl Into<String>) -> Self {
13        Self {
14            api_key: api_key.into(),
15            config: CaptchaConfig::default(),
16        }
17    }
18
19    pub fn with_config(api_key: impl Into<String>, config: CaptchaConfig) -> Self {
20        Self {
21            api_key: api_key.into(),
22            config,
23        }
24    }
25}
26
27#[async_trait]
28impl CaptchaProvider for TwoCaptchaProvider {
29    fn name(&self) -> &'static str {
30        "twocaptcha"
31    }
32
33    async fn solve(&self, _task: &CaptchaTask) -> CaptchaResult {
34        Err(CaptchaError::NotImplemented(self.name()))
35    }
36}