From 83448fd0fbc0065bc1f1e4d90b08fbaa9d16630f Mon Sep 17 00:00:00 2001 From: realaravinth Date: Thu, 16 Dec 2021 14:51:06 +0530 Subject: [PATCH] guard unsafe code behind separate module to satisfy clippy --- src/lib.rs | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6251d28..1ad05f6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,8 +14,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#![allow(clippy::not_unsafe_ptr_arg_deref)] - use lazy_static::lazy_static; use redis_module::NotifyEvent; use redis_module::{redis_command, redis_event_handler, redis_module}; @@ -80,22 +78,27 @@ pub fn on_delete(ctx: &Context, event_type: NotifyEvent, event: &str, key_name: } } -redis_module! { - name: "mcaptcha_cahce", - version: PKG_VERSION, - data_types: [MCAPTCHA_BUCKET_TYPE, MCAPTCHA_MCAPTCHA_TYPE, MCAPTCHA_SAFETY_TYPE, MCAPTCHA_CHALLENGE_TYPE], - commands: [ - ["MCAPTCHA_CACHE.ADD_VISITOR", bucket::Bucket::counter_create, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.GET", mcaptcha::MCaptcha::get_count, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.ADD_CAPTCHA", mcaptcha::MCaptcha::add_captcha, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.DELETE_CAPTCHA", mcaptcha::MCaptcha::delete_captcha, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.RENAME_CAPTCHA", mcaptcha::MCaptcha::rename, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.CAPTCHA_EXISTS", mcaptcha::MCaptcha::captcha_exists, "readonly", 1, 1, 1], - ["MCAPTCHA_CACHE.ADD_CHALLENGE", challenge::Challenge::create_challenge, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.GET_CHALLENGE", challenge::Challenge::get_challenge, "write", 1, 1, 1], - ["MCAPTCHA_CACHE.DELETE_CHALLENGE", challenge::Challenge::delete_challenge, "write", 1, 1, 1], - ], - event_handlers: [ - [@EXPIRED @EVICTED: on_delete], - ] +#[allow(clippy::not_unsafe_ptr_arg_deref)] +pub mod redis { + use super::*; + + redis_module! { + name: "mcaptcha_cahce", + version: PKG_VERSION, + data_types: [MCAPTCHA_BUCKET_TYPE, MCAPTCHA_MCAPTCHA_TYPE, MCAPTCHA_SAFETY_TYPE, MCAPTCHA_CHALLENGE_TYPE], + commands: [ + ["MCAPTCHA_CACHE.ADD_VISITOR", bucket::Bucket::counter_create, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.GET", mcaptcha::MCaptcha::get_count, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.ADD_CAPTCHA", mcaptcha::MCaptcha::add_captcha, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.DELETE_CAPTCHA", mcaptcha::MCaptcha::delete_captcha, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.RENAME_CAPTCHA", mcaptcha::MCaptcha::rename, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.CAPTCHA_EXISTS", mcaptcha::MCaptcha::captcha_exists, "readonly", 1, 1, 1], + ["MCAPTCHA_CACHE.ADD_CHALLENGE", challenge::Challenge::create_challenge, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.GET_CHALLENGE", challenge::Challenge::get_challenge, "write", 1, 1, 1], + ["MCAPTCHA_CACHE.DELETE_CHALLENGE", challenge::Challenge::delete_challenge, "write", 1, 1, 1], + ], + event_handlers: [ + [@EXPIRED @EVICTED: on_delete], + ] + } }