use serde::{Deserialize, Serialize};
pub use crate::profile::{
ProfileProperty, TextureEntry, TextureMetadata, TextureType, TexturesPayload,
};
use crate::error::{Error, Result};
use crate::profile::decode_textures_property;
use crate::uuid::McUuid;
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct GameProfile {
pub id: McUuid,
pub name: String,
#[serde(default)]
pub properties: Vec<ProfileProperty>,
}
impl GameProfile {
pub fn decode_textures(&self) -> Result<TexturesPayload> {
decode_textures_property(&self.properties)?.ok_or(Error::MissingTexturesProperty)
}
}
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct NameUuidEntry {
pub id: McUuid,
pub name: String,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
pub enum SkinModel {
#[default]
#[serde(rename = "default", alias = "")]
Classic,
#[serde(rename = "slim")]
Slim,
}
impl SkinModel {
#[must_use]
pub const fn as_form_value(self) -> &'static str {
match self {
SkinModel::Classic => "",
SkinModel::Slim => "slim",
}
}
}