Derive Debug, start debugging

This commit is contained in:
bitfl0wer 2023-04-14 23:38:36 +02:00
parent 3e405169e3
commit ead320f145
2 changed files with 23 additions and 3 deletions

View File

@ -5,7 +5,7 @@ pub mod limits {
use serde::{Deserialize, Serialize};
use serde_json::from_str;
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
#[derive(Clone, Copy, Eq, Hash, PartialEq, Debug)]
pub enum LimitType {
AuthRegister,
AuthLogin,
@ -134,7 +134,7 @@ pub mod limits {
pub absoluteRate: AbsoluteRate,
}
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
pub struct Limit {
pub bucket: LimitType,
pub limit: u64,

View File

@ -7,11 +7,13 @@ use std::collections::{HashMap, VecDeque};
// request checks for all the request limiters that apply, and blocks if any of the limiters are 0
#[allow(dead_code)]
#[derive(Debug)]
pub struct TypedRequest {
request: RequestBuilder,
limit_type: LimitType,
}
#[derive(Debug)]
pub struct LimitedRequester {
http: Client,
requests: VecDeque<TypedRequest>,
@ -186,3 +188,21 @@ impl LimitedRequester {
}
}
}
#[cfg(test)]
mod tests {
use crate::URLBundle;
use super::*;
#[tokio::test]
async fn test() {
let urls = URLBundle::new(
String::from("http://localhost:3001/api/"),
String::from("wss://localhost:3001/"),
String::from("http://localhost:3001/cdn"),
);
let requester = LimitedRequester::new(urls.api).await;
}
}