Add rate limiting example
This commit is contained in:
parent
508f697a51
commit
44319feb79
|
@ -0,0 +1,27 @@
|
|||
use listenbrainz::raw::Client;
|
||||
|
||||
fn main() {
|
||||
let token = std::env::args().nth(1).expect("No token provided");
|
||||
|
||||
let client = Client::new();
|
||||
|
||||
loop {
|
||||
match client.validate_token(&token) {
|
||||
Ok(response) => {
|
||||
println!("{:?}", response.rate_limit);
|
||||
|
||||
if let Some(remaining) = response.rate_limit.map(|r| r.remaining) {
|
||||
if remaining == 0 {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("{}", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue