twilight_http/request/application/command/
delete_global_command.rs1#[cfg(not(target_os = "wasi"))]
2use crate::response::{Response, ResponseFuture, marker::EmptyBody};
3use crate::{
4 client::Client,
5 error::Error,
6 request::{Request, TryIntoRequest},
7 routing::Route,
8};
9use std::future::IntoFuture;
10use twilight_model::id::{
11 Id,
12 marker::{ApplicationMarker, CommandMarker},
13};
14
15#[must_use = "requests must be configured and executed"]
17pub struct DeleteGlobalCommand<'a> {
18 application_id: Id<ApplicationMarker>,
19 command_id: Id<CommandMarker>,
20 http: &'a Client,
21}
22
23impl<'a> DeleteGlobalCommand<'a> {
24 pub(crate) const fn new(
25 http: &'a Client,
26 application_id: Id<ApplicationMarker>,
27 command_id: Id<CommandMarker>,
28 ) -> Self {
29 Self {
30 application_id,
31 command_id,
32 http,
33 }
34 }
35}
36
37#[cfg(not(target_os = "wasi"))]
38impl IntoFuture for DeleteGlobalCommand<'_> {
39 type Output = Result<Response<EmptyBody>, Error>;
40
41 type IntoFuture = ResponseFuture<EmptyBody>;
42
43 fn into_future(self) -> Self::IntoFuture {
44 let http = self.http;
45
46 match self.try_into_request() {
47 Ok(request) => http.request(request),
48 Err(source) => ResponseFuture::error(source),
49 }
50 }
51}
52
53impl TryIntoRequest for DeleteGlobalCommand<'_> {
54 fn try_into_request(self) -> Result<Request, Error> {
55 Ok(Request::from_route(&Route::DeleteGlobalCommand {
56 application_id: self.application_id.get(),
57 command_id: self.command_id.get(),
58 }))
59 }
60}