pub trait ClientDefault<'a>: Clone + Sized {
    type Error: Error + Send + Sync + 'static;

    fn default_client_with_name(
        product: Option<HeaderValue>
    ) -> Result<Self, Self::Error>; fn default_client() -> Self { ... } }
Available on crate feature client only.
Expand description

A specific client default for setting some sane defaults for API calls and oauth2 usage

Required Associated Types

Errors that can happen when assembling the client

Required Methods

Constructs Self with sane defaults for API calls and oauth2 and setting user-agent to include another product

Specifically, one should

  • Set User-Agent to {product} twitch_api/{version_of_twitch_api} (According to RFC7231) See TWITCH_API_USER_AGENT for the product of this crate
  • Disallow redirects
Notes

When the product name is none, this function should never fail. This should be ensured with tests.

Provided Methods

Construct Self with sane defaults for API calls and oauth2.

Examples found in repository?
src/tmi/mod.rs (line 53)
51
52
53
54
55
    pub fn new() -> TmiClient<'a, C>
    where C: crate::client::ClientDefault<'a> {
        let client = C::default_client();
        TmiClient::with_client(client)
    }
More examples
Hide additional examples
src/helix/client.rs (line 85)
83
84
85
86
87
    pub fn new() -> HelixClient<'a, C>
    where C: crate::client::ClientDefault<'a> {
        let client = C::default_client();
        HelixClient::with_client(client)
    }
src/lib.rs (line 199)
197
198
199
200
201
    pub fn new() -> TwitchClient<'static, C>
    where C: Clone + client::ClientDefault<'static> {
        let client = C::default_client();
        Self::with_client(client)
    }

Implementations on Foreign Types

Implementors