pub fn client(&self) -> Result<Client> {
        let mut headers = self.custom_headers.clone();
        headers.insert(header::USER_AGENT, HeaderValue::from_str(&self.user_agent)?);
        headers.insert(
            header::TRANSFER_ENCODING,
            HeaderValue::from_static("chunked"),
        );

        let builder = reqwest::ClientBuilder::new()
            .gzip(true)
            .default_headers(headers)
            .danger_accept_invalid_certs(self.allow_insecure)
            .redirect(reqwest::redirect::Policy::limited(self.max_redirects));

        let reqwest_client = (match self.timeout {
            Some(t) => builder.timeout(t),
            None => builder,
        })
        .build()?;

        let github_token = match self.github_token {
            Some(ref token) if !token.is_empty() => Some(Github::new(
                self.user_agent.clone(),
                Credentials::Token(token.clone()),
            )?),
            _ => None,
        };

        let filter = self.build_filter();

        let quirks = Quirks::default();

        Ok(Client {
            reqwest_client,
            github_client: github_token,
            filter,
            method: self.method.clone(),
            accepted: self.accepted.clone(),
            require_https: self.require_https,
            quirks,
        })
    }
/// The build method instantiates the client.
///
/// # Errors
///
/// Returns an `Err` if:
/// - The user agent cannot be parsed
/// - The request client cannot be created
/// - The Github client cannot be created
The build method instantiates the client.
The build method instantiates the client .
pub fn client(&self) -> Result<Client> {
        let mut headers = self.custom_headers.clone();
        headers.insert(header::USER_AGENT, HeaderValue::from_str(&self.user_agent)?);
        headers.insert(
            header::TRANSFER_ENCODING,
            HeaderValue::from_static("chunked"),
        );
        let builder = reqwest::ClientBuilder::new()
            .gzip(true)
            .default_headers(headers)
            .danger_accept_invalid_certs(self.allow_insecure)
            .redirect(reqwest::redirect::Policy::limited(self.max_redirects));
        let reqwest_client = (match self.timeout {
            Some(t) => builder.timeout(t),
            None => builder,
        })
        .build()?;
        let github_token = match self.github_token {
            Some(ref token) if !token.is_empty() => Some(Github::new(
                self.user_agent.clone(),
                Credentials::Token(token.clone()),
            )?),
            _ => None,
        };
        let filter = self.build_filter();
        let quirks = Quirks::default();
        Ok(Client {
            reqwest_client,
            github_client: github_token,
            filter,
            method: self.method.clone(),
            accepted: self.accepted.clone(),
            require_https: self.require_https,
            quirks,
        })
    }
pub fn client ( & self ) -> Result < Client > { let mut headers = self . custom_headers . clone ( ) ; headers . insert ( header :: USER_AGENT , HeaderValue :: from_str ( & self . user_agent ) ? ) ; headers . insert ( header :: TRANSFER_ENCODING , HeaderValue :: from_static ( " " ) , ) ; let builder = reqwest :: ClientBuilder :: new ( ) . gzip ( true ) . default_headers ( headers ) . danger_accept_invalid_certs ( self . allow_insecure ) . redirect ( reqwest :: redirect :: Policy :: limited ( self . max_redirects ) ) ; let reqwest_client = ( match self . timeout { Some ( t ) => builder . timeout ( t ) , None => builder , } ) . build ( ) ? ; let github_token = match self . github_token { Some ( ref token ) if ! token . is_empty ( ) => Some ( Github :: new ( self . user_agent . clone ( ) , Credentials :: Token ( token . clone ( ) ) , ) ? ) , _ => None , } ; let filter = self . build_filter ( ) ; let quirks = Quirks :: default ( ) ; Ok ( Client { reqwest_client , github_client : github_token , filter , method : self . method . clone ( ) , accepted : self . accepted . clone ( ) , require_https : self . require_https , quirks , } ) }
The build method instantiates the client.
The build method instantiates the client .
&self
errors
Returns an `Err` if:
The user agent cannot be parsed
The request client cannot be created
The Github client cannot be created
Returns an ` Err ` if : The user agent cannot be parsed The request client cannot be created The Github client cannot be created