-use crate::{APIError, IPAddr, LemmyError};
+use crate::{ApiError, IpAddr, LemmyError};
use log::debug;
use std::{collections::HashMap, time::SystemTime};
use strum::IntoEnumIterator;
/// Rate limiting based on rate type and IP addr
#[derive(Debug, Clone)]
pub struct RateLimiter {
- buckets: HashMap<RateLimitType, HashMap<IPAddr, RateLimitBucket>>,
+ buckets: HashMap<RateLimitType, HashMap<IpAddr, RateLimitBucket>>,
}
impl Default for RateLimiter {
fn default() -> Self {
Self {
- buckets: HashMap::<RateLimitType, HashMap<IPAddr, RateLimitBucket>>::new(),
+ buckets: HashMap::<RateLimitType, HashMap<IpAddr, RateLimitBucket>>::new(),
}
}
}
rate_limit.allowance
);
Err(
- APIError {
+ ApiError {
message: format!(
"Too many requests. type: {}, IP: {}, {} per {} seconds",
type_.as_ref(),