use hyper::{body::Bytes, StatusCode};
use serde::Deserialize;
use crate::{request::Requestable, ClientError};
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
pub struct SkinInfo {
#[serde(rename = "skinName")]
pub name: Box<str>,
#[serde(rename = "skinAuthor")]
pub author: Box<str>,
#[serde(rename = "downloadLink")]
pub download_link: Box<str>,
}
impl Requestable for SkinInfo {
fn response_error(status: StatusCode, bytes: Bytes) -> ClientError {
if status == StatusCode::NOT_FOUND {
match serde_json::from_slice(&bytes) {
Ok(error) => ClientError::SkinDeleted { error },
Err(source) => ClientError::Parsing {
body: bytes.into(),
source,
},
}
} else {
ClientError::response_error(bytes, status.as_u16())
}
}
}
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
pub struct SkinDeleted {
pub found: bool,
pub removed: bool,
pub message: Box<str>,
pub name: Option<Box<str>>,
pub author: Option<Box<str>>,
}