| Crates.io | twilight-http |
| lib.rs | twilight-http |
| version | 0.16.0 |
| created_at | 2020-08-30 02:53:27.313753+00 |
| updated_at | 2025-01-12 09:48:02.044842+00 |
| description | Discord REST API client for the Twilight ecosystem. |
| homepage | https://twilight.rs/chapter_1_crates/section_2_http.html |
| repository | https://github.com/twilight-rs/twilight.git |
| max_upload_size | |
| id | 282536 |
| size | 1,125,528 |
HTTP support for the twilight ecosystem.
There are a few usage examples located in the root of the twilight
repository.
Using rustls for TLS requires configuring a crypto provider via crate
features or manually installing a global default. The default is rustls-ring.
rustls-ringThe rustls-ring feature will enable the use of ring as the crypto
provider. This is recommended for platform compatibility.
rustls-aws_lc_rsThe rustls-aws_lc_rs feature will enable the use of aws-lc-rs as the
crypto provider. This is recommended for performance and on widely used
platforms.
If none of the other crypto providers are enabled, a custom one must be
installed by the application using CryptoProvider::install_default.
The decompression feature enables brotli decompression support via the brotli crate.
This is enabled by default.
twilight-http supports serde_json and simd-json for deserializing
responses.
simd-jsonThe 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-native-roots", "simd-json"], version = "0.2" }
Note: not enabling any TLS feature is supported for use behind a proxy; Discord's API is HTTPS only.
twilight-http has features to enable HTTPS connectivity with hyper. These
features are mutually exclusive. rustls-platform-verifier is enabled by default.
native-tlsThe native-tls feature uses a HTTPS connector provided by hyper-tls.
To enable native-tls, do something like this in your Cargo.toml:
[dependencies]
twilight-http = { default-features = false, features = ["native"], version = "0.2" }
rustls-native-rootsThe rustls-native-roots feature uses a HTTPS connector provided by hyper-rustls, which uses
rustls as the TLS backend, and enables its native-tokio feature, which uses rustls-native-certs
for root certificates. This requires configuring a crypto provider.
rustls-platform-verifierThe rustls-platform-verifier feature uses a HTTPS connector provided by hyper-rustls, which uses
rustls as the TLS backend, and enables its rustls-platform-verifier feature, which uses
rustls-platform-verifier for certificate validation. This requires configuring a crypto provider.
This is enabled by default.
rustls-webpki-rootsThe rustls-webpki-roots feature uses a HTTPS connector provided by hyper-rustls, which uses
rustls as the TLS backend, and enables its webpki-tokio feature, which uses webpki-roots
for root certificates. This requires configuring a crypto provider.
This should be preferred over rustls-native-roots in Docker containers based on scratch.
The hickory feature enables hyper-hickory, which replaces the default
GaiResolver in hyper. hyper-hickory instead provides a fully async
DNS resolver on the application level.