twilight_model/channel/message/sticker/
pack.rs

1use super::Sticker;
2use crate::id::{
3    marker::{StickerBannerAssetMarker, StickerMarker, StickerPackMarker, StickerPackSkuMarker},
4    Id,
5};
6use serde::{Deserialize, Serialize};
7
8/// Pack of [`Standard`] stickers.
9///
10/// [`Standard`]: super::StickerType::Standard
11#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
12pub struct StickerPack {
13    /// ID of the sticker pack's banner image.
14    pub banner_asset_id: Option<Id<StickerBannerAssetMarker>>,
15    /// ID of the sticker that is shown as the pack's icon.
16    pub cover_sticker_id: Option<Id<StickerMarker>>,
17    /// Description of the sticker pack.
18    pub description: String,
19    /// ID of the sticker pack.
20    pub id: Id<StickerPackMarker>,
21    /// Name of the sticker pack.
22    pub name: String,
23    /// ID of the pack's SKU.
24    pub sku_id: Id<StickerPackSkuMarker>,
25    /// List of stickers in the pack.
26    pub stickers: Vec<Sticker>,
27}
28
29#[cfg(test)]
30mod tests {
31    use super::{
32        super::{StickerFormatType, StickerType},
33        Sticker, StickerPack,
34    };
35    use crate::id::Id;
36    use serde::{Deserialize, Serialize};
37    use serde_test::Token;
38    use static_assertions::{assert_fields, assert_impl_all};
39    use std::{fmt::Debug, hash::Hash};
40
41    assert_fields!(
42        StickerPack: banner_asset_id,
43        cover_sticker_id,
44        description,
45        id,
46        name,
47        sku_id,
48        stickers
49    );
50
51    assert_impl_all!(
52        StickerPack: Clone,
53        Debug,
54        Deserialize<'static>,
55        Eq,
56        Hash,
57        PartialEq,
58        Send,
59        Serialize,
60        Sync,
61    );
62
63    #[test]
64    fn full() {
65        let value = StickerPack {
66            banner_asset_id: Some(Id::new(761_773_777_976_819_732)),
67            cover_sticker_id: Some(Id::new(749_053_689_419_006_003)),
68            description: "Say hello to Wumpus!".into(),
69            id: Id::new(847_199_849_233_514_549),
70            name: "Wumpus Beyond".into(),
71            sku_id: Id::new(847_199_849_233_514_547),
72            stickers: Vec::from([Sticker {
73                available: true,
74                description: Some("Wumpus waves hello".into()),
75                format_type: StickerFormatType::Lottie,
76                guild_id: None,
77                id: Id::new(749_054_660_769_218_631),
78                kind: StickerType::Standard,
79                name: "Wave".into(),
80                pack_id: Some(Id::new(847_199_849_233_514_549)),
81                sort_value: Some(12),
82                tags: "wumpus, hello, sup, hi, oi, heyo, heya, yo, wave".into(),
83                user: None,
84            }]),
85        };
86
87        serde_test::assert_tokens(
88            &value,
89            &[
90                Token::Struct {
91                    name: "StickerPack",
92                    len: 7,
93                },
94                Token::Str("banner_asset_id"),
95                Token::Some,
96                Token::NewtypeStruct { name: "Id" },
97                Token::Str("761773777976819732"),
98                Token::Str("cover_sticker_id"),
99                Token::Some,
100                Token::NewtypeStruct { name: "Id" },
101                Token::Str("749053689419006003"),
102                Token::Str("description"),
103                Token::Str("Say hello to Wumpus!"),
104                Token::Str("id"),
105                Token::NewtypeStruct { name: "Id" },
106                Token::Str("847199849233514549"),
107                Token::Str("name"),
108                Token::Str("Wumpus Beyond"),
109                Token::Str("sku_id"),
110                Token::NewtypeStruct { name: "Id" },
111                Token::Str("847199849233514547"),
112                Token::Str("stickers"),
113                Token::Seq { len: Some(1) },
114                Token::Struct {
115                    name: "Sticker",
116                    len: 9,
117                },
118                Token::Str("available"),
119                Token::Bool(true),
120                Token::Str("description"),
121                Token::Some,
122                Token::Str("Wumpus waves hello"),
123                Token::Str("format_type"),
124                Token::U8(3),
125                Token::Str("id"),
126                Token::NewtypeStruct { name: "Id" },
127                Token::Str("749054660769218631"),
128                Token::Str("type"),
129                Token::U8(1),
130                Token::Str("name"),
131                Token::Str("Wave"),
132                Token::Str("pack_id"),
133                Token::Some,
134                Token::NewtypeStruct { name: "Id" },
135                Token::Str("847199849233514549"),
136                Token::Str("sort_value"),
137                Token::Some,
138                Token::U64(12),
139                Token::Str("tags"),
140                Token::Str("wumpus, hello, sup, hi, oi, heyo, heya, yo, wave"),
141                Token::StructEnd,
142                Token::SeqEnd,
143                Token::StructEnd,
144            ],
145        );
146    }
147}