Skip to main content

twilight_http/request/
get_user_application.rs

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