twilight_http/request/application/emoji/
delete_emoji.rs

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