File: get_rate_limit.rs

package info (click to toggle)
rust-octocrab 0.43.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,532 kB
  • sloc: makefile: 2
file content (13 lines) | stat: -rw-r--r-- 528 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
use octocrab::Octocrab;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let ratelimit = octocrab::instance().ratelimit().get().await?;
    println!("{}", serde_json::to_string_pretty(&ratelimit)?);

    let token = std::env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN env variable is required");
    let octocrab = Octocrab::builder().personal_token(token).build()?;
    let ratelimit = octocrab.ratelimit().get().await?;
    println!("{}", serde_json::to_string_pretty(&ratelimit)?);
    Ok(())
}