twilight_http/request/application/command/
get_global_command.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::{
10 application::command::Command,
11 id::{
12 marker::{ApplicationMarker, CommandMarker},
13 Id,
14 },
15};
16
17#[must_use = "requests must be configured and executed"]
19pub struct GetGlobalCommand<'a> {
20 application_id: Id<ApplicationMarker>,
21 command_id: Id<CommandMarker>,
22 http: &'a Client,
23}
24
25impl<'a> GetGlobalCommand<'a> {
26 pub(crate) const fn new(
27 http: &'a Client,
28 application_id: Id<ApplicationMarker>,
29 command_id: Id<CommandMarker>,
30 ) -> Self {
31 Self {
32 application_id,
33 command_id,
34 http,
35 }
36 }
37}
38
39impl IntoFuture for GetGlobalCommand<'_> {
40 type Output = Result<Response<Command>, Error>;
41
42 type IntoFuture = ResponseFuture<Command>;
43
44 fn into_future(self) -> Self::IntoFuture {
45 let http = self.http;
46
47 match self.try_into_request() {
48 Ok(request) => http.request(request),
49 Err(source) => ResponseFuture::error(source),
50 }
51 }
52}
53
54impl TryIntoRequest for GetGlobalCommand<'_> {
55 fn try_into_request(self) -> Result<Request, Error> {
56 Ok(Request::from_route(&Route::GetGlobalCommand {
57 application_id: self.application_id.get(),
58 command_id: self.command_id.get(),
59 }))
60 }
61}