use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum TextureModel {
#[default]
Steve,
Alex,
Cape,
}
impl TextureModel {
pub const fn as_str(self) -> &'static str {
match self {
TextureModel::Steve => "steve",
TextureModel::Alex => "alex",
TextureModel::Cape => "cape",
}
}
}
#[derive(Clone, Copy, Debug, Default, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum SkinlibFilter {
#[default]
Skin,
Steve,
Alex,
Cape,
}
impl SkinlibFilter {
pub const fn as_str(self) -> &'static str {
match self {
SkinlibFilter::Skin => "skin",
SkinlibFilter::Steve => "steve",
SkinlibFilter::Alex => "alex",
SkinlibFilter::Cape => "cape",
}
}
}
#[derive(Clone, Copy, Debug, Default, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum SkinlibSort {
#[default]
Time,
Likes,
}
impl SkinlibSort {
pub const fn as_str(self) -> &'static str {
match self {
SkinlibSort::Time => "time",
SkinlibSort::Likes => "likes",
}
}
}
#[derive(Clone, Debug, Default, Serialize)]
pub struct SkinlibListQuery {
pub filter: Option<SkinlibFilter>,
pub sort: Option<SkinlibSort>,
pub keyword: Option<String>,
pub uploader: Option<u64>,
pub page: Option<u32>,
}
impl SkinlibListQuery {
pub fn new() -> Self {
Self::default()
}
pub fn filter(mut self, filter: SkinlibFilter) -> Self {
self.filter = Some(filter);
self
}
pub fn sort(mut self, sort: SkinlibSort) -> Self {
self.sort = Some(sort);
self
}
pub fn keyword(mut self, keyword: impl Into<String>) -> Self {
self.keyword = Some(keyword.into());
self
}
pub fn uploader(mut self, uid: u64) -> Self {
self.uploader = Some(uid);
self
}
pub fn page(mut self, page: u32) -> Self {
self.page = Some(page);
self
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SkinlibItem {
pub tid: u64,
pub name: String,
#[serde(rename = "type")]
pub texture_type: TextureModel,
pub uploader: u64,
pub public: bool,
#[serde(default)]
pub likes: u64,
#[serde(default)]
pub hash: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TextureDetail {
pub tid: u64,
pub name: String,
#[serde(rename = "type")]
pub texture_type: TextureModel,
pub hash: String,
pub size: u64,
pub uploader: u64,
pub public: bool,
#[serde(default)]
pub likes: u64,
#[serde(default)]
pub upload_at: Option<String>,
}
#[derive(Clone, Debug)]
pub struct UploadTextureRequest {
pub name: String,
pub texture_type: TextureModel,
pub public: bool,
pub file_name: String,
pub png_bytes: Vec<u8>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct UploadedTexture {
pub tid: u64,
pub name: String,
#[serde(rename = "type")]
pub texture_type: TextureModel,
pub hash: String,
pub public: bool,
}
#[derive(Clone, Copy, Debug, Default, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum ClosetCategory {
#[default]
Skin,
Cape,
}
impl ClosetCategory {
pub const fn as_str(self) -> &'static str {
match self {
ClosetCategory::Skin => "skin",
ClosetCategory::Cape => "cape",
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ClosetItem {
pub tid: u64,
pub name: String,
#[serde(rename = "type")]
pub texture_type: TextureModel,
pub hash: String,
#[serde(default)]
pub pivot: Option<serde_json::Value>,
}