addressing clippy lints
This commit is contained in:
parent
705c39af13
commit
0ff9cf9cb0
4 changed files with 18 additions and 26 deletions
10
src/cache/hashcache.rs
vendored
10
src/cache/hashcache.rs
vendored
|
@ -48,7 +48,7 @@ impl HashCache {
|
||||||
// retrive [PoWConfig] from cache. Deletes config post retrival
|
// retrive [PoWConfig] from cache. Deletes config post retrival
|
||||||
fn retrive_pow_config(&mut self, string: String) -> CaptchaResult<Option<CachedPoWConfig>> {
|
fn retrive_pow_config(&mut self, string: String) -> CaptchaResult<Option<CachedPoWConfig>> {
|
||||||
if let Some(difficulty_factor) = self.remove_pow_config(&string) {
|
if let Some(difficulty_factor) = self.remove_pow_config(&string) {
|
||||||
Ok(Some(difficulty_factor.to_owned()))
|
Ok(Some(difficulty_factor))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ impl HashCache {
|
||||||
fn verify_captcha_result(&mut self, challenge: VerifyCaptchaResult) -> CaptchaResult<bool> {
|
fn verify_captcha_result(&mut self, challenge: VerifyCaptchaResult) -> CaptchaResult<bool> {
|
||||||
if let Some(captcha_id) = self.remove_cache_result(&challenge.token) {
|
if let Some(captcha_id) = self.remove_cache_result(&challenge.token) {
|
||||||
if captcha_id == challenge.key {
|
if captcha_id == challenge.key {
|
||||||
return Ok(true);
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
return Ok(false);
|
Ok(false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
@ -101,7 +101,7 @@ impl Handler<CachePoW> for HashCache {
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let del_msg = DeletePoW(msg.string.clone());
|
let del_msg = DeletePoW(msg.string.clone());
|
||||||
|
|
||||||
let duration: Duration = Duration::new(msg.duration.clone(), 0);
|
let duration: Duration = Duration::new(msg.duration, 0);
|
||||||
let wait_for = async move {
|
let wait_for = async move {
|
||||||
//sleep(duration).await;
|
//sleep(duration).await;
|
||||||
delay_for(duration).await;
|
delay_for(duration).await;
|
||||||
|
@ -144,7 +144,7 @@ impl Handler<CacheResult> for HashCache {
|
||||||
token: msg.token.clone(),
|
token: msg.token.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let duration: Duration = Duration::new(msg.duration.clone(), 0);
|
let duration: Duration = Duration::new(msg.duration, 0);
|
||||||
let wait_for = async move {
|
let wait_for = async move {
|
||||||
//sleep(duration).await;
|
//sleep(duration).await;
|
||||||
delay_for(duration).await;
|
delay_for(duration).await;
|
||||||
|
|
|
@ -284,7 +284,7 @@ pub mod tests {
|
||||||
Some(CaptchaError::PleaseSetValue("defense".into()))
|
Some(CaptchaError::PleaseSetValue("defense".into()))
|
||||||
);
|
);
|
||||||
|
|
||||||
let m = MCaptchaBuilder::default().defense(defense.clone()).build();
|
let m = MCaptchaBuilder::default().defense(defense).build();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
m.err(),
|
m.err(),
|
||||||
Some(CaptchaError::PleaseSetValue("duration".into()))
|
Some(CaptchaError::PleaseSetValue("duration".into()))
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl MasterTrait for Master {}
|
||||||
impl Master {
|
impl Master {
|
||||||
/// add [Counter] actor to [Master]
|
/// add [Counter] actor to [Master]
|
||||||
pub fn add_site(&mut self, addr: Addr<Counter>, id: String) {
|
pub fn add_site(&mut self, addr: Addr<Counter>, id: String) {
|
||||||
self.sites.insert(id, (None, addr.to_owned()));
|
self.sites.insert(id, (None, addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// create new master
|
/// create new master
|
||||||
|
@ -58,7 +58,7 @@ impl Master {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get [Counter] actor from [Master]
|
/// get [Counter] actor from [Master]
|
||||||
pub fn get_site<'a, 'b>(&'a mut self, id: &'b str) -> Option<Addr<Counter>> {
|
pub fn get_site(&mut self, id: &str) -> Option<Addr<Counter>> {
|
||||||
let mut r = None;
|
let mut r = None;
|
||||||
if let Some((read_val, addr)) = self.sites.get_mut(id) {
|
if let Some((read_val, addr)) = self.sites.get_mut(id) {
|
||||||
r = Some(addr.clone());
|
r = Some(addr.clone());
|
||||||
|
@ -111,7 +111,7 @@ impl Handler<AddVisitor> for Master {
|
||||||
ctx.spawn(fut);
|
ctx.spawn(fut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return MessageResult(rx);
|
MessageResult(rx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +125,9 @@ impl Handler<GetSite> for Master {
|
||||||
|
|
||||||
fn handle(&mut self, m: GetSite, _ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, m: GetSite, _ctx: &mut Self::Context) -> Self::Result {
|
||||||
let addr = self.get_site(&m.0);
|
let addr = self.get_site(&m.0);
|
||||||
if addr.is_none() {
|
match addr {
|
||||||
return MessageResult(None);
|
None => MessageResult(None),
|
||||||
} else {
|
Some(addr) => MessageResult(Some(addr)),
|
||||||
return MessageResult(Some(addr.unwrap().clone()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,24 +77,17 @@ impl MCaptchaRedisConnection {
|
||||||
let commands = vec![ADD_VISITOR, ADD_CAPTCHA, DEL, CAPTCHA_EXISTS, GET];
|
let commands = vec![ADD_VISITOR, ADD_CAPTCHA, DEL, CAPTCHA_EXISTS, GET];
|
||||||
|
|
||||||
for cmd in commands.iter() {
|
for cmd in commands.iter() {
|
||||||
match self
|
if let Value::Bulk(mut val) = self
|
||||||
.0
|
.0
|
||||||
.exec(redis::cmd("COMMAND").arg(&["INFO", cmd]))
|
.exec(redis::cmd("COMMAND").arg(&["INFO", cmd]))
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
{
|
{
|
||||||
Value::Bulk(mut val) => {
|
if let Some(Value::Nil) = val.pop() {
|
||||||
match val.pop() {
|
return Err(CaptchaError::MCaptchaRediSModuleCommandNotFound(
|
||||||
Some(Value::Nil) => {
|
cmd.to_string(),
|
||||||
return Err(CaptchaError::MCaptchaRediSModuleCommandNotFound(
|
));
|
||||||
cmd.to_string(),
|
};
|
||||||
))
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
_ => (),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue