twilight_http/request/guild/
get_guild_welcome_screen.rs1#[cfg(not(target_os = "wasi"))]
2use crate::response::{Response, ResponseFuture};
3use crate::{
4 client::Client,
5 error::Error,
6 request::{Request, TryIntoRequest},
7 routing::Route,
8};
9use std::future::IntoFuture;
10use twilight_model::{
11 guild::invite::WelcomeScreen,
12 id::{Id, marker::GuildMarker},
13};
14
15#[must_use = "requests must be configured and executed"]
22pub struct GetGuildWelcomeScreen<'a> {
23 guild_id: Id<GuildMarker>,
24 http: &'a Client,
25}
26
27impl<'a> GetGuildWelcomeScreen<'a> {
28 pub(crate) const fn new(http: &'a Client, guild_id: Id<GuildMarker>) -> Self {
29 Self { guild_id, http }
30 }
31}
32
33#[cfg(not(target_os = "wasi"))]
34impl IntoFuture for GetGuildWelcomeScreen<'_> {
35 type Output = Result<Response<WelcomeScreen>, Error>;
36
37 type IntoFuture = ResponseFuture<WelcomeScreen>;
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 GetGuildWelcomeScreen<'_> {
50 fn try_into_request(self) -> Result<Request, Error> {
51 Ok(Request::from_route(&Route::GetGuildWelcomeScreen {
52 guild_id: self.guild_id.get(),
53 }))
54 }
55}