add umbrella crate

This commit is contained in:
Aleksandr 2025-09-20 22:55:40 +03:00
parent d171fc723b
commit fe04530f84
17 changed files with 247 additions and 5 deletions

32
captcha/src/lib.rs Normal file
View file

@ -0,0 +1,32 @@
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")
}
}
}