twilight_http/request/guild/sticker/
get_guild_stickers.rs1#[cfg(not(target_os = "wasi"))]
2use crate::response::{Response, ResponseFuture, marker::ListBody};
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::{Id, marker::GuildMarker},
13};
14
15pub struct GetGuildStickers<'a> {
34 guild_id: Id<GuildMarker>,
35 http: &'a Client,
36}
37
38impl<'a> GetGuildStickers<'a> {
39 pub(crate) const fn new(http: &'a Client, guild_id: Id<GuildMarker>) -> Self {
40 Self { guild_id, http }
41 }
42}
43
44#[cfg(not(target_os = "wasi"))]
45impl IntoFuture for GetGuildStickers<'_> {
46 type Output = Result<Response<ListBody<Sticker>>, Error>;
47
48 type IntoFuture = ResponseFuture<ListBody<Sticker>>;
49
50 fn into_future(self) -> Self::IntoFuture {
51 let http = self.http;
52
53 match self.try_into_request() {
54 Ok(request) => http.request(request),
55 Err(source) => ResponseFuture::error(source),
56 }
57 }
58}
59
60impl TryIntoRequest for GetGuildStickers<'_> {
61 fn try_into_request(self) -> Result<Request, Error> {
62 Ok(Request::from_route(&Route::GetGuildStickers {
63 guild_id: self.guild_id.get(),
64 }))
65 }
66}