pub fn new(duration: Duration, user_agent: &str) -> Result<Self, Box<std::error::Error>> {
        let ratelimit = ratelimit::Builder::new()
            .capacity(1) //number of tokens the bucket will hold
            .quantum(1) //add one token per interval
            .interval(duration) //add quantum tokens every `duration`
            .build();

        let mut reqwest_headers = reqwest::header::HeaderMap::new();
        reqwest_headers.insert(
            reqwest::header::USER_AGENT,
            reqwest::header::HeaderValue::from_str(user_agent)?
        );

        let reqwest_client = reqwest::Client::builder()
            .default_headers(reqwest_headers)
            .build()?;

        Ok(Self {
            reqwest_client,
            ratelimit,
        })
    }
/// Create a Hammock that rate-limits requests to one request per `duration`.
Create a Hammock that rate-limits requests to one request per `duration`.
Create a Hammock that rate - limits requests to one request per ` duration ` .
pub fn new(duration: Duration, user_agent: &str) -> Result<Self, Box<std::error::Error>> {
        let ratelimit = ratelimit::Builder::new()
            .capacity(1) //number of tokens the bucket will hold
            .quantum(1) //add one token per interval
            .interval(duration) //add quantum tokens every `duration`
            .build();
        let mut reqwest_headers = reqwest::header::HeaderMap::new();
        reqwest_headers.insert(
            reqwest::header::USER_AGENT,
            reqwest::header::HeaderValue::from_str(user_agent)?
        );
        let reqwest_client = reqwest::Client::builder()
            .default_headers(reqwest_headers)
            .build()?;
        Ok(Self {
            reqwest_client,
            ratelimit,
        })
    }
pub fn new ( duration : Duration , user_agent : & str ) -> Result < Self , Box < std :: error :: Error > > { let ratelimit = ratelimit :: Builder :: new ( ) . capacity ( 1 ) //number of tokens the bucket will hold . quantum ( 1 ) //add one token per interval . interval ( duration ) //add quantum tokens every `duration` . build ( ) ; let mut reqwest_headers = reqwest :: header :: HeaderMap :: new ( ) ; reqwest_headers . insert ( reqwest :: header :: USER_AGENT , reqwest :: header :: HeaderValue :: from_str ( user_agent ) ? ) ; let reqwest_client = reqwest :: Client :: builder ( ) . default_headers ( reqwest_headers ) . build ( ) ? ; Ok ( Self { reqwest_client , ratelimit , } ) }
Create a Hammock that rate-limits requests to one request per `duration`.
Create a Hammock that rate - limits requests to one request per ` duration ` .
duration
Duration
user_agent
&str
duration
Duration
user_agent
&str