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