twilight_http/request/guild/
delete_guild.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::{Id, marker::GuildMarker};
11
12#[must_use = "requests must be configured and executed"]
14pub struct DeleteGuild<'a> {
15 guild_id: Id<GuildMarker>,
16 http: &'a Client,
17}
18
19impl<'a> DeleteGuild<'a> {
20 pub(crate) const fn new(http: &'a Client, guild_id: Id<GuildMarker>) -> Self {
21 Self { guild_id, http }
22 }
23}
24
25#[cfg(not(target_os = "wasi"))]
26impl IntoFuture for DeleteGuild<'_> {
27 type Output = Result<Response<EmptyBody>, Error>;
28
29 type IntoFuture = ResponseFuture<EmptyBody>;
30
31 fn into_future(self) -> Self::IntoFuture {
32 let http = self.http;
33
34 match self.try_into_request() {
35 Ok(request) => http.request(request),
36 Err(source) => ResponseFuture::error(source),
37 }
38 }
39}
40
41impl TryIntoRequest for DeleteGuild<'_> {
42 fn try_into_request(self) -> Result<Request, Error> {
43 Ok(Request::from_route(&Route::DeleteGuild {
44 guild_id: self.guild_id.get(),
45 }))
46 }
47}