modio/request/user/
get_authenticated_user.rs1use std::future::IntoFuture;
2
3use crate::client::Client;
4use crate::request::{Output, RequestBuilder, Route};
5use crate::response::ResponseFuture;
6use crate::types::User;
7
8pub struct GetAuthenticatedUser<'a> {
10 http: &'a Client,
11}
12
13impl<'a> GetAuthenticatedUser<'a> {
14 pub(crate) const fn new(http: &'a Client) -> Self {
15 Self { http }
16 }
17}
18
19impl IntoFuture for GetAuthenticatedUser<'_> {
20 type Output = Output<User>;
21 type IntoFuture = ResponseFuture<User>;
22
23 fn into_future(self) -> Self::IntoFuture {
24 let route = Route::UserAuthenticated;
25
26 match RequestBuilder::from_route(&route).empty() {
27 Ok(req) => self.http.request(req),
28 Err(err) => ResponseFuture::failed(err),
29 }
30 }
31}