twilight_model/user/
avatar_decoration_data.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use serde::{Deserialize, Serialize};

use crate::{
    id::{marker::AvatarDecorationDataSkuMarker, Id},
    util::ImageHash,
};

/// The data for the user's avatar decoration.
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct AvatarDecorationData {
    /// The avatar decoration hash.
    pub asset: ImageHash,
    /// ID of the avatar decoration's SKU.
    pub sku_id: Id<AvatarDecorationDataSkuMarker>,
}

#[cfg(test)]
mod tests {
    use super::{AvatarDecorationData, Id, ImageHash};
    use serde_test::Token;

    #[test]
    fn test_avatar_decoration_data() {
        let hash = "b2a6536641da91a0b59bd66557c56c36";
        let value = AvatarDecorationData {
            asset: ImageHash::parse(hash.as_bytes()).unwrap(),
            sku_id: Id::new(1),
        };

        serde_test::assert_tokens(
            &value,
            &[
                Token::Struct {
                    name: "AvatarDecorationData",
                    len: 2,
                },
                Token::Str("asset"),
                Token::Str(hash),
                Token::Str("sku_id"),
                Token::NewtypeStruct { name: "Id" },
                Token::Str("1"),
                Token::StructEnd,
            ],
        );
    }
}