twilight_http/request/
get_user_application.rs

1use 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::oauth::Application;
10
11#[must_use = "requests must be configured and executed"]
12pub struct GetUserApplicationInfo<'a> {
13    http: &'a Client,
14}
15
16impl<'a> GetUserApplicationInfo<'a> {
17    pub(crate) const fn new(http: &'a Client) -> Self {
18        Self { http }
19    }
20}
21
22impl IntoFuture for GetUserApplicationInfo<'_> {
23    type Output = Result<Response<Application>, Error>;
24
25    type IntoFuture = ResponseFuture<Application>;
26
27    fn into_future(self) -> Self::IntoFuture {
28        let http = self.http;
29
30        match self.try_into_request() {
31            Ok(request) => http.request(request),
32            Err(source) => ResponseFuture::error(source),
33        }
34    }
35}
36
37impl TryIntoRequest for GetUserApplicationInfo<'_> {
38    fn try_into_request(self) -> Result<Request, Error> {
39        Ok(Request::from_route(&Route::GetCurrentUserApplicationInfo))
40    }
41}