Skip to main content

elemental_core/auth/
texture.rs

1use serde::{Deserialize, Serialize};
2
3/// Texture kinds that can be read from or changed on a Minecraft profile.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5#[serde(rename_all = "lowercase")]
6pub enum TextureType {
7    Skin,
8    Cape,
9}
10
11#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(rename_all = "lowercase")]
13pub enum SkinModel {
14    #[default]
15    Classic,
16    Slim,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
20pub struct Skin {
21    pub url: String,
22    pub model: SkinModel,
23}
24
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct Cape {
27    /// Selectable cape identifier when the provider exposes a cape inventory.
28    pub id: Option<String>,
29    pub alias: Option<String>,
30    pub url: String,
31    pub active: bool,
32}
33
34#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
35pub struct ProfileTextures {
36    pub skin: Option<Skin>,
37    /// Capes available for selection. Yggdrasil reports only the active texture.
38    pub capes: Vec<Cape>,
39    /// Texture kinds this account accepts through upload.
40    pub uploadable: Vec<TextureType>,
41}
42
43impl ProfileTextures {
44    pub fn active_cape(&self) -> Option<&Cape> {
45        self.capes.iter().find(|cape| cape.active)
46    }
47}