Crate twilight_http[][src]

Expand description

twilight-http

codecov badge discord badge github badge license badge rust badge

HTTP support for the twilight ecosystem.

Examples

There are a few usage examples located in the root of the twilight repository.

Features

Decompression

The decompression feature enables brotli decompression support via the brotli crate.

This is enabled by default.

Deserialization

twilight-http supports serde_json and simd-json for deserializing responses.

simd-json

The simd-json feature enables simd-json support to use simd features of modern cpus to deserialize responses faster. It is not enabled by default.

To use this feature you need to also add these lines to <project root>/.cargo/config:

[build]
rustflags = ["-C", "target-cpu=native"]

You can also set the environment variable RUSTFLAGS="-C target-cpu=native". If you enable both serde_json and simd-json at the same time, then simd-json will be used.

To enable simd-json, do something like this in your Cargo.toml:

[dependencies]
twilight-http = { default-features = false, features = ["rustls", "simd-json"], version = "0.2" }

TLS

twilight-http has features to enable hyper’s TLS features. These features are mutually exclusive. rustls is enabled by default.

native

The native feature enables hyper’s default-tls feature, which is mostly equivalent to using native-tls.

To enable native, do something like this in your Cargo.toml:

[dependencies]
twilight-http = { default-features = false, features = ["native"], version = "0.2" }
rustls

The rustls feature enables hyper’s rustls feature, which uses rustls as the TLS backend.

This is enabled by default.

Tracing

The tracing feature enables logging via the tracing crate.

This is enabled by default.

Trust-DNS

The trust-dns enables hyper-trust-dns, which replaces the default GaiResolver in hyper. hyper-trust-dns instead provides a fully async DNS resolver on the application level.

Re-exports

pub use crate::client::Client;
pub use crate::error::Error;
pub use crate::response::Response;

Modules

Response utility type and related types.

Constants

Discord API version used by this crate.