twilight_http/request/application/command/
delete_global_command.rs

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