use async_trait::async_trait;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Verdict {
pub ok: bool,
pub reason: Option<String>,
}
#[derive(Debug, Clone, Error)]
pub enum CaptchaError {
#[error("captcha transport error: {0}")]
Transport(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CaptchaBinding {
pub hostname_bound: bool,
pub action_bound: bool,
pub fail_open: bool,
}
#[async_trait]
pub trait Captcha: Send + Sync {
async fn verify(&self, token: &str, remote_ip: Option<&str>) -> Result<Verdict, CaptchaError>;
#[must_use]
fn binding(&self) -> Option<CaptchaBinding> {
None
}
}