add umbrella crate
This commit is contained in:
parent
d171fc723b
commit
fe04530f84
17 changed files with 247 additions and 5 deletions
32
captcha/src/lib.rs
Normal file
32
captcha/src/lib.rs
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue