add bucket identifiers, add check_limits stub
This commit is contained in:
parent
79cdc6e315
commit
3e84976256
23
src/limit.rs
23
src/limit.rs
|
@ -1,16 +1,17 @@
|
||||||
use reqwest::{Client, Request};
|
use reqwest::{Client, Request};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
struct Limit {
|
pub struct Limit {
|
||||||
limit: i64,
|
limit: i64,
|
||||||
remaining: i64,
|
remaining: i64,
|
||||||
reset: i64,
|
reset: i64,
|
||||||
|
bucket: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LimitedRequester {
|
pub struct LimitedRequester {
|
||||||
http: Client,
|
http: Client,
|
||||||
limit: Limit,
|
limit: Limit,
|
||||||
requests: VecDeque<Request>, // wow, amazing
|
requests: VecDeque<Request>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LimitedRequester {
|
impl LimitedRequester {
|
||||||
|
@ -21,12 +22,24 @@ impl LimitedRequester {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
LimitedRequester {
|
LimitedRequester {
|
||||||
limit: Limit {
|
limit: Limit {
|
||||||
limit: 1,
|
limit: -1,
|
||||||
remaining: 1,
|
remaining: -1,
|
||||||
reset: 0,
|
reset: -1,
|
||||||
|
bucket: String::new(),
|
||||||
},
|
},
|
||||||
http: Client::new(),
|
http: Client::new(),
|
||||||
requests: VecDeque::new(),
|
requests: VecDeque::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check_limits(url: String) -> Limit {
|
||||||
|
let client = Client::new();
|
||||||
|
let url_parsed = crate::URLBundle::parse_url(url);
|
||||||
|
Limit {
|
||||||
|
limit: -1,
|
||||||
|
remaining: -1,
|
||||||
|
reset: -1,
|
||||||
|
bucket: String::new(),
|
||||||
|
} // TODO: Implement
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue