Struct twilight_http::client::ClientBuilder[][src]

pub struct ClientBuilder { /* fields omitted */ }

A builder for Client.

Implementations

impl ClientBuilder[src]

pub fn new() -> Self[src]

Create a new builder to create a Client.

pub fn build(self) -> Client[src]

Build the Client.

pub fn default_allowed_mentions(self, allowed_mentions: AllowedMentions) -> Self[src]

Set the default allowed mentions setting to use on all messages sent through the HTTP client.

pub fn hyper_client(
    self,
    client: HyperClient<HttpsConnector<HttpConnector>>
) -> Self
[src]

Set a pre-configured Hyper client builder to build off of.

The proxy and timeout settings in the Hyper client will be overridden by those in this builder.

The default client uses Rustls as its TLS backend.

pub fn proxy(self, proxy_url: impl Into<String>, use_http: bool) -> Self[src]

Set the proxy to use for all HTTP(S) requests.

Note that this isn’t currently a traditional proxy, but is for working with something like twilight’s HTTP proxy server.

Examples

Set the proxy to twilight_http_proxy.internal:

use twilight_http::Client;

let client = Client::builder()
    .proxy("twilight_http_proxy.internal", true)
    .build();

pub fn ratelimiter(self, ratelimiter: impl Into<Option<Ratelimiter>>) -> Self[src]

Set a ratelimiter to use.

If the argument is None then the client’s ratelimiter will be skipped before making a request.

If this method is not called at all then a default ratelimiter will be created by ClientBuilder::build.

pub fn timeout(self, duration: Duration) -> Self[src]

Set the timeout for HTTP requests.

The default is 10 seconds.

pub fn default_headers(self, headers: HeaderMap) -> Self[src]

Set a group headers which are sent in every request.

pub fn token(self, token: impl Into<String>) -> Self[src]

Set the token to use for HTTP requests.

Trait Implementations

impl Debug for ClientBuilder[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for ClientBuilder[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V