use error::NekrochanError; use lazy_static::lazy_static; use std::{collections::HashMap, sync::RwLock}; lazy_static! { pub static ref CAPTCHA: RwLock> = RwLock::new(HashMap::new()); } pub mod auth; pub mod cfg; pub mod ctx; pub mod db; pub mod error; pub mod files; pub mod filters; pub mod markup; pub mod perms; pub mod qsform; pub mod trip; pub mod web; pub fn paginate(page_size: i64, count: i64) -> i64 { count / page_size + (count % page_size).signum() } pub fn check_page( page: i64, pages: i64, page_limit: impl Into>, ) -> Result<(), NekrochanError> { if page <= 0 || (page > pages && page != 1) { return Err(NekrochanError::InvalidPageError); } if let Some(page_limit) = page_limit.into() { if page > page_limit { return Err(NekrochanError::InvalidPageError); } } Ok(()) }