1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Github RateLimit API

use crate::{models, Octocrab, Result};

/// Handler for GitHub's rate_limit API.
///
/// Created with [`Octocrab::ratelimit`].
pub struct RateLimitHandler<'octo> {
    crab: &'octo Octocrab,
}

impl<'octo> RateLimitHandler<'octo> {
    pub(crate) fn new(crab: &'octo Octocrab) -> Self {
        Self { crab }
    }

    /// Get the rate limit.
    /// ```no_run
    /// # async fn run() -> octocrab::Result<()> {
    /// let ratelimit = octocrab::instance()
    ///     .ratelimit()
    ///     .get()
    ///     .await?;
    /// # Ok(())
    /// # }
    /// ```
    pub async fn get(&self) -> Result<models::RateLimit> {
        self.crab.get("/rate_limit", None::<&()>).await
    }
}