core/captcha/src/lib.rs
2025-09-25 20:36:05 +03:00

32 lines
591 B
Rust

use eva::fut::Fut;
use viendesu_core::{
bail,
types::captcha::Token,
world::{World, WorldMut},
};
use self::error::CaptchaResult;
pub mod error;
pub trait Service: Send + Sync {
fn verify<W: WorldMut>(
&self,
w: World<W>,
token: &Token,
) -> impl Fut<Output = CaptchaResult<()>>;
}
impl Service for bool {
async fn verify<W: WorldMut>(&self, w: World<W>, token: &Token) -> CaptchaResult<()> {
_ = w;
_ = token;
if *self {
Ok(())
} else {
bail!("invalid captcha")
}
}
}