twilight_http/request/guild/sticker/
get_guild_sticker.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 channel::message::sticker::Sticker,
12 id::{
13 Id,
14 marker::{GuildMarker, StickerMarker},
15 },
16};
17
18pub struct GetGuildSticker<'a> {
42 guild_id: Id<GuildMarker>,
43 http: &'a Client,
44 sticker_id: Id<StickerMarker>,
45}
46
47impl<'a> GetGuildSticker<'a> {
48 pub(crate) const fn new(
49 http: &'a Client,
50 guild_id: Id<GuildMarker>,
51 sticker_id: Id<StickerMarker>,
52 ) -> Self {
53 Self {
54 guild_id,
55 http,
56 sticker_id,
57 }
58 }
59}
60
61#[cfg(not(target_os = "wasi"))]
62impl IntoFuture for GetGuildSticker<'_> {
63 type Output = Result<Response<Sticker>, Error>;
64
65 type IntoFuture = ResponseFuture<Sticker>;
66
67 fn into_future(self) -> Self::IntoFuture {
68 let http = self.http;
69
70 match self.try_into_request() {
71 Ok(request) => http.request(request),
72 Err(source) => ResponseFuture::error(source),
73 }
74 }
75}
76
77impl TryIntoRequest for GetGuildSticker<'_> {
78 fn try_into_request(self) -> Result<Request, Error> {
79 Ok(Request::from_route(&Route::GetGuildSticker {
80 guild_id: self.guild_id.get(),
81 sticker_id: self.sticker_id.get(),
82 }))
83 }
84}