twilight_http/request/sticker/
get_nitro_sticker_packs.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 serde::Deserialize;
10use std::future::IntoFuture;
11use twilight_model::channel::message::sticker::StickerPack;
12
13#[derive(Deserialize)]
14pub struct StickerPackListing {
15 pub sticker_packs: Vec<StickerPack>,
16}
17
18#[must_use = "requests must be configured and executed"]
35pub struct GetNitroStickerPacks<'a> {
36 http: &'a Client,
37}
38
39impl<'a> GetNitroStickerPacks<'a> {
40 pub(crate) const fn new(http: &'a Client) -> Self {
41 Self { http }
42 }
43}
44
45#[cfg(not(target_os = "wasi"))]
46impl IntoFuture for GetNitroStickerPacks<'_> {
47 type Output = Result<Response<StickerPackListing>, Error>;
48
49 type IntoFuture = ResponseFuture<StickerPackListing>;
50
51 fn into_future(self) -> Self::IntoFuture {
52 let http = self.http;
53
54 match self.try_into_request() {
55 Ok(request) => http.request(request),
56 Err(source) => ResponseFuture::error(source),
57 }
58 }
59}
60
61impl TryIntoRequest for GetNitroStickerPacks<'_> {
62 fn try_into_request(self) -> Result<Request, Error> {
63 Ok(Request::from_route(&Route::GetNitroStickerPacks))
64 }
65}