rosu_render/request/
skin_custom.rs

1use std::future::IntoFuture;
2
3use serde::Serialize;
4
5use crate::{model::SkinInfo, request::Request, routing::Route, ClientError, OrdrClient};
6
7use super::OrdrFuture;
8
9#[derive(Serialize)]
10struct GetSkinCustomFields {
11    id: u32,
12}
13
14/// Get [`SkinInfo`] of a custom skin.
15#[must_use]
16pub struct GetSkinCustom<'a> {
17    ordr: &'a OrdrClient,
18    fields: GetSkinCustomFields,
19}
20
21impl<'a> GetSkinCustom<'a> {
22    pub(crate) const fn new(ordr: &'a OrdrClient, id: u32) -> Self {
23        Self {
24            ordr,
25            fields: GetSkinCustomFields { id },
26        }
27    }
28}
29
30impl IntoFuture for &mut GetSkinCustom<'_> {
31    type Output = Result<SkinInfo, ClientError>;
32    type IntoFuture = OrdrFuture<SkinInfo>;
33
34    fn into_future(self) -> Self::IntoFuture {
35        match Request::builder(Route::SkinCustom).query(&self.fields) {
36            Ok(builder) => self.ordr.request(builder.build()),
37            Err(err) => OrdrFuture::error(err),
38        }
39    }
40}
41
42impl IntoFuture for GetSkinCustom<'_> {
43    type Output = Result<SkinInfo, ClientError>;
44    type IntoFuture = OrdrFuture<SkinInfo>;
45
46    fn into_future(mut self) -> Self::IntoFuture {
47        (&mut self).into_future()
48    }
49}