twilight_http/request/
get_gateway_authed.rs1use crate::{
2 client::Client,
3 error::Error,
4 request::{Request, TryIntoRequest},
5 response::{Response, ResponseFuture},
6 routing::Route,
7};
8use std::future::IntoFuture;
9use twilight_model::gateway::connection_info::BotConnectionInfo;
10
11#[must_use = "requests must be configured and executed"]
16pub struct GetGatewayAuthed<'a> {
17 http: &'a Client,
18}
19
20impl<'a> GetGatewayAuthed<'a> {
21 pub(crate) const fn new(http: &'a Client) -> Self {
22 Self { http }
23 }
24}
25
26impl IntoFuture for GetGatewayAuthed<'_> {
27 type Output = Result<Response<BotConnectionInfo>, Error>;
28
29 type IntoFuture = ResponseFuture<BotConnectionInfo>;
30
31 fn into_future(self) -> Self::IntoFuture {
32 let http = self.http;
33
34 match self.try_into_request() {
35 Ok(request) => http.request(request),
36 Err(source) => ResponseFuture::error(source),
37 }
38 }
39}
40
41impl TryIntoRequest for GetGatewayAuthed<'_> {
42 fn try_into_request(self) -> Result<Request, Error> {
43 Ok(Request::from_route(&Route::GetGatewayBot))
44 }
45}