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