captcha_sdk/provider.rs
1use std::{future::Future, pin::Pin};
2
3use crate::{ProviderId, VerificationError, VerificationRequest, VerificationResult};
4
5/// The boxed future returned by an object-safe [`CaptchaVerifier`].
6pub type VerificationFuture<'a> =
7 Pin<Box<dyn Future<Output = Result<VerificationResult, VerificationError>> + Send + 'a>>;
8
9/// Provider-independent interface implemented by CAPTCHA adapters.
10pub trait CaptchaVerifier: Send + Sync {
11 /// Identifies the backing provider.
12 fn provider(&self) -> &ProviderId;
13
14 /// Verifies a client token and returns a normalized result.
15 fn verify(&self, request: VerificationRequest) -> VerificationFuture<'_>;
16}