Module twilight_http::response [−][src]
Expand description
Response utility type and related types.
The heart of the response module is the Response itself: it’s a wrapper
over the underlying HTTP client’s response, containing helper methods for
things like getting the raw bytes of the response body, getting
an iterator of the response headers, or
deserializing the body into a model.
The ResponseFuture is a type implementing Future that resolves to a
Response when polled or .awaited to completion.
Examples
Get a user by ID, check if the request was successful, and if so deserialize
the response body via Response::model and print the user’s
name:
use std::env; use twilight_http::Client; let client = Client::new(env::var("DISCORD_TOKEN")?); let response = client.user(user_id).exec().await?; if !response.status().is_success() { println!("failed to get user"); return Ok(()); } // Twilight already knows to deserialize it into a // `twilight_model::user::User`. let user = response.model().await?; println!("user's name: {}:{}", user.name, user.discriminator);
Modules
Markers denoting the type of response body.
Structs
Future resolving to the bytes of a response body.
Failure when processing a response body.
Iterator over the headers of a Response.
Future resolving to a deserialized Member.
Future resolving to a deserialized list of Members.
Future resolving to a deserialized model.
Response wrapper containing helper functions over the HTTP client’s response.
Future that will resolve to a Response.
Status code of a response.
Future resolving to the text of a response body.
Enums
Type of DeserializeBodyError that occurred.