rosu_render/model/
skin_custom.rs

1use hyper::{body::Bytes, StatusCode};
2use serde::Deserialize;
3
4use crate::{request::Requestable, ClientError};
5
6/// Information about a custom skin.
7#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
8pub struct SkinInfo {
9    /// The name of the skin.
10    #[serde(rename = "skinName")]
11    pub name: Box<str>,
12    /// The author (skinner, parsed from the skin's skin.ini) of the skin.
13    #[serde(rename = "skinAuthor")]
14    pub author: Box<str>,
15    /// The download link for this custom skin, from issou.best servers.
16    #[serde(rename = "downloadLink")]
17    pub download_link: Box<str>,
18}
19
20impl Requestable for SkinInfo {
21    fn response_error(status: StatusCode, bytes: Bytes) -> ClientError {
22        if status == StatusCode::NOT_FOUND {
23            match serde_json::from_slice(&bytes) {
24                Ok(error) => ClientError::SkinDeleted { error },
25                Err(source) => ClientError::Parsing {
26                    body: bytes.into(),
27                    source,
28                },
29            }
30        } else {
31            ClientError::response_error(bytes, status.as_u16())
32        }
33    }
34}
35
36#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
37pub struct SkinDeleted {
38    /// true if found, false if not.
39    pub found: bool,
40    /// true if removed, false if not.
41    pub removed: bool,
42    /// The info message, in english, of an error.
43    pub message: Box<str>,
44    /// The name of the skin.
45    pub name: Option<Box<str>>,
46    /// The author (skinner, parsed from the skin's skin.ini) of the skin.
47    pub author: Option<Box<str>>,
48}