twilight_http/request/guild/sticker/
get_guild_sticker.rs1use crate::{
2 client::Client,
3 error::Error,
4 request::{Request, TryIntoRequest},
5 response::{Response, ResponseFuture},
6 routing::Route,
7};
8use std::future::IntoFuture;
9use twilight_model::{
10 channel::message::sticker::Sticker,
11 id::{
12 marker::{GuildMarker, StickerMarker},
13 Id,
14 },
15};
16
17pub struct GetGuildSticker<'a> {
41 guild_id: Id<GuildMarker>,
42 http: &'a Client,
43 sticker_id: Id<StickerMarker>,
44}
45
46impl<'a> GetGuildSticker<'a> {
47 pub(crate) const fn new(
48 http: &'a Client,
49 guild_id: Id<GuildMarker>,
50 sticker_id: Id<StickerMarker>,
51 ) -> Self {
52 Self {
53 guild_id,
54 http,
55 sticker_id,
56 }
57 }
58}
59
60impl IntoFuture for GetGuildSticker<'_> {
61 type Output = Result<Response<Sticker>, Error>;
62
63 type IntoFuture = ResponseFuture<Sticker>;
64
65 fn into_future(self) -> Self::IntoFuture {
66 let http = self.http;
67
68 match self.try_into_request() {
69 Ok(request) => http.request(request),
70 Err(source) => ResponseFuture::error(source),
71 }
72 }
73}
74
75impl TryIntoRequest for GetGuildSticker<'_> {
76 fn try_into_request(self) -> Result<Request, Error> {
77 Ok(Request::from_route(&Route::GetGuildSticker {
78 guild_id: self.guild_id.get(),
79 sticker_id: self.sticker_id.get(),
80 }))
81 }
82}