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