diff --git a/twilight-cache-inmemory/src/event/interaction.rs b/twilight-cache-inmemory/src/event/interaction.rs index 55bd040ac6d..52ecf9ddfb4 100644 --- a/twilight-cache-inmemory/src/event/interaction.rs +++ b/twilight-cache-inmemory/src/event/interaction.rs @@ -169,6 +169,7 @@ mod tests { accent_color: None, avatar: Some(avatar3), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -250,6 +251,7 @@ mod tests { accent_color: None, avatar: Some(avatar2), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 5678, @@ -289,6 +291,7 @@ mod tests { accent_color: None, avatar: Some(avatar3), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1234, diff --git a/twilight-cache-inmemory/src/event/message.rs b/twilight-cache-inmemory/src/event/message.rs index 2f7fabfa15a..181b5333a1e 100644 --- a/twilight-cache-inmemory/src/event/message.rs +++ b/twilight-cache-inmemory/src/event/message.rs @@ -121,6 +121,7 @@ mod tests { accent_color: None, avatar: Some(avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-cache-inmemory/src/event/voice_state.rs b/twilight-cache-inmemory/src/event/voice_state.rs index 1c068139d68..31e19a7f7b4 100644 --- a/twilight-cache-inmemory/src/event/voice_state.rs +++ b/twilight-cache-inmemory/src/event/voice_state.rs @@ -307,6 +307,7 @@ mod tests { accent_color: None, avatar: Some(avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-cache-inmemory/src/model/member.rs b/twilight-cache-inmemory/src/model/member.rs index 3a88609373a..7cbbfd9207e 100644 --- a/twilight-cache-inmemory/src/model/member.rs +++ b/twilight-cache-inmemory/src/model/member.rs @@ -339,6 +339,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-cache-inmemory/src/model/sticker.rs b/twilight-cache-inmemory/src/model/sticker.rs index 2e4cbe53de2..1e7b880932b 100644 --- a/twilight-cache-inmemory/src/model/sticker.rs +++ b/twilight-cache-inmemory/src/model/sticker.rs @@ -211,6 +211,7 @@ mod tests { accent_color: None, avatar: Some(avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-cache-inmemory/src/test.rs b/twilight-cache-inmemory/src/test.rs index 7278a410a2d..b5854dc4a9e 100644 --- a/twilight-cache-inmemory/src/test.rs +++ b/twilight-cache-inmemory/src/test.rs @@ -45,6 +45,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache { accent_color: None, avatar: Some(avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -122,6 +123,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache { accent_color: None, avatar: Some(avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -163,6 +165,7 @@ pub fn cache_with_message_and_reactions() -> DefaultInMemoryCache { accent_color: None, avatar: Some(user_5_avatar), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 2, @@ -358,6 +361,7 @@ pub fn user(id: Id) -> User { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: Some(banner), bot: false, discriminator: 1, diff --git a/twilight-model/src/application/interaction/mod.rs b/twilight-model/src/application/interaction/mod.rs index cf2d561d7f1..168ee512c95 100644 --- a/twilight-model/src/application/interaction/mod.rs +++ b/twilight-model/src/application/interaction/mod.rs @@ -514,6 +514,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1111, @@ -554,6 +555,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1111, @@ -672,7 +674,7 @@ mod tests { Token::Str("600"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -681,6 +683,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -744,7 +748,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -753,6 +757,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/application/interaction/resolved.rs b/twilight-model/src/application/interaction/resolved.rs index 75513e7975c..291e01ea2de 100644 --- a/twilight-model/src/application/interaction/resolved.rs +++ b/twilight-model/src/application/interaction/resolved.rs @@ -180,6 +180,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -263,6 +264,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -382,7 +384,7 @@ mod tests { Token::Str("author"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -391,6 +393,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -520,7 +524,7 @@ mod tests { Token::Str("300"), Token::Struct { name: "User", - len: 16, + len: 17, }, Token::Str("accent_color"), Token::None, @@ -529,6 +533,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/channel/message/interaction.rs b/twilight-model/src/channel/message/interaction.rs index 4e282256d11..d32abc3b997 100644 --- a/twilight-model/src/channel/message/interaction.rs +++ b/twilight-model/src/channel/message/interaction.rs @@ -64,6 +64,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: Some(image_hash::BANNER), bot: false, discriminator: 1, @@ -128,7 +129,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 16, + len: 17, }, Token::Str("accent_color"), Token::None, @@ -137,6 +138,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::Some, Token::Str(image_hash::BANNER_INPUT), diff --git a/twilight-model/src/channel/message/mod.rs b/twilight-model/src/channel/message/mod.rs index e0027daa52f..2558ef88aef 100644 --- a/twilight-model/src/channel/message/mod.rs +++ b/twilight-model/src/channel/message/mod.rs @@ -228,6 +228,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -299,7 +300,7 @@ mod tests { Token::Str("author"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -308,6 +309,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -431,6 +434,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -557,7 +561,7 @@ mod tests { Token::Str("author"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -566,6 +570,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/channel/message/sticker/mod.rs b/twilight-model/src/channel/message/sticker/mod.rs index 256c20ab587..86ec53f1290 100644 --- a/twilight-model/src/channel/message/sticker/mod.rs +++ b/twilight-model/src/channel/message/sticker/mod.rs @@ -155,6 +155,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -212,7 +213,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 17, + len: 18, }, Token::Str("accent_color"), Token::None, @@ -221,6 +222,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/channel/webhook/mod.rs b/twilight-model/src/channel/webhook/mod.rs index 66cff9e06e4..5a6ed12e573 100644 --- a/twilight-model/src/channel/webhook/mod.rs +++ b/twilight-model/src/channel/webhook/mod.rs @@ -158,6 +158,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -241,7 +242,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -249,6 +250,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/gateway/event/dispatch.rs b/twilight-model/src/gateway/event/dispatch.rs index 1b7ab66604e..2d1fa3eec36 100644 --- a/twilight-model/src/gateway/event/dispatch.rs +++ b/twilight-model/src/gateway/event/dispatch.rs @@ -15,9 +15,9 @@ use serde::{ #[serde(untagged)] pub enum DispatchEvent { AutoModerationActionExecution(AutoModerationActionExecution), - AutoModerationRuleCreate(Box), - AutoModerationRuleDelete(Box), - AutoModerationRuleUpdate(Box), + AutoModerationRuleCreate(AutoModerationRuleCreate), + AutoModerationRuleDelete(AutoModerationRuleDelete), + AutoModerationRuleUpdate(AutoModerationRuleUpdate), BanAdd(BanAdd), BanRemove(BanRemove), ChannelCreate(Box), @@ -242,15 +242,15 @@ impl<'de, 'a> DeserializeSeed<'de> for DispatchEventWithTypeDeserializer<'a> { "AUTO_MODERATION_ACTION_EXECUTION" => DispatchEvent::AutoModerationActionExecution( AutoModerationActionExecution::deserialize(deserializer)?, ), - "AUTO_MODERATION_RULE_CREATE" => DispatchEvent::AutoModerationRuleCreate(Box::new( + "AUTO_MODERATION_RULE_CREATE" => DispatchEvent::AutoModerationRuleCreate( AutoModerationRuleCreate::deserialize(deserializer)?, - )), - "AUTO_MODERATION_RULE_DELETE" => DispatchEvent::AutoModerationRuleDelete(Box::new( + ), + "AUTO_MODERATION_RULE_DELETE" => DispatchEvent::AutoModerationRuleDelete( AutoModerationRuleDelete::deserialize(deserializer)?, - )), - "AUTO_MODERATION_RULE_UPDATE" => DispatchEvent::AutoModerationRuleUpdate(Box::new( + ), + "AUTO_MODERATION_RULE_UPDATE" => DispatchEvent::AutoModerationRuleUpdate( AutoModerationRuleUpdate::deserialize(deserializer)?, - )), + ), "CHANNEL_CREATE" => { DispatchEvent::ChannelCreate(Box::new(ChannelCreate::deserialize(deserializer)?)) } diff --git a/twilight-model/src/gateway/event/mod.rs b/twilight-model/src/gateway/event/mod.rs index 26ef405f755..26d5df63c4a 100644 --- a/twilight-model/src/gateway/event/mod.rs +++ b/twilight-model/src/gateway/event/mod.rs @@ -27,11 +27,11 @@ pub enum Event { /// Message was blocked by AutoMod according to a rule. AutoModerationActionExecution(AutoModerationActionExecution), /// Sent when an auto moderation rule is created. - AutoModerationRuleCreate(Box), + AutoModerationRuleCreate(AutoModerationRuleCreate), /// Sent when an auto moderation rule is deleted. - AutoModerationRuleDelete(Box), + AutoModerationRuleDelete(AutoModerationRuleDelete), /// Sent when an auto moderation rule is updated. - AutoModerationRuleUpdate(Box), + AutoModerationRuleUpdate(AutoModerationRuleUpdate), /// A user was banned from a guild. BanAdd(BanAdd), /// A user's ban from a guild was removed. @@ -457,14 +457,11 @@ mod tests { // requires a variable to be used in a function, so this is a false // positive. #[allow(dead_code)] - const EVENT_THRESHOLD: usize = 224; + const EVENT_THRESHOLD: usize = 256; const_assert!(mem::size_of::() == EVENT_THRESHOLD); // Boxed events. - const_assert!(mem::size_of::() > EVENT_THRESHOLD); - const_assert!(mem::size_of::() > EVENT_THRESHOLD); - const_assert!(mem::size_of::() > EVENT_THRESHOLD); const_assert!(mem::size_of::() > EVENT_THRESHOLD); const_assert!(mem::size_of::() > EVENT_THRESHOLD); const_assert!(mem::size_of::() > EVENT_THRESHOLD); @@ -491,6 +488,9 @@ mod tests { const_assert!(mem::size_of::() > EVENT_THRESHOLD); // Unboxed. + const_assert!(mem::size_of::() <= EVENT_THRESHOLD); + const_assert!(mem::size_of::() <= EVENT_THRESHOLD); + const_assert!(mem::size_of::() <= EVENT_THRESHOLD); const_assert!(mem::size_of::() <= EVENT_THRESHOLD); const_assert!(mem::size_of::() <= EVENT_THRESHOLD); const_assert!(mem::size_of::() <= EVENT_THRESHOLD); diff --git a/twilight-model/src/gateway/payload/incoming/member_add.rs b/twilight-model/src/gateway/payload/incoming/member_add.rs index 63fc759f81d..a2e4567b18f 100644 --- a/twilight-model/src/gateway/payload/incoming/member_add.rs +++ b/twilight-model/src/gateway/payload/incoming/member_add.rs @@ -60,6 +60,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 987, @@ -105,7 +106,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 8, + len: 9, }, Token::Str("accent_color"), Token::None, @@ -113,6 +114,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/gateway/payload/incoming/member_chunk.rs b/twilight-model/src/gateway/payload/incoming/member_chunk.rs index 2a3d8118797..e46c2458f4c 100644 --- a/twilight-model/src/gateway/payload/incoming/member_chunk.rs +++ b/twilight-model/src/gateway/payload/incoming/member_chunk.rs @@ -310,6 +310,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: true, discriminator: 1, @@ -341,6 +342,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: true, discriminator: 1, @@ -372,6 +374,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -403,6 +406,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-model/src/gateway/payload/incoming/member_update.rs b/twilight-model/src/gateway/payload/incoming/member_update.rs index e933ea5c5b9..bdc4f9bdd94 100644 --- a/twilight-model/src/gateway/payload/incoming/member_update.rs +++ b/twilight-model/src/gateway/payload/incoming/member_update.rs @@ -41,6 +41,7 @@ mod tests { use serde_test::Token; #[test] + #[allow(clippy::too_many_lines)] fn member_update() { let joined_at = Some(Timestamp::from_micros(1_488_234_110_121_000).expect("non zero")); let communication_disabled_until = @@ -60,6 +61,7 @@ mod tests { user: User { accent_color: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, name: "Twilight Sparkle".to_string(), public_flags: None, @@ -115,7 +117,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -124,6 +126,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/gateway/payload/incoming/thread_members_update.rs b/twilight-model/src/gateway/payload/incoming/thread_members_update.rs index 8c040356d33..4e54e59424d 100644 --- a/twilight-model/src/gateway/payload/incoming/thread_members_update.rs +++ b/twilight-model/src/gateway/payload/incoming/thread_members_update.rs @@ -126,6 +126,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -260,6 +261,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/gateway/payload/incoming/typing_start.rs b/twilight-model/src/gateway/payload/incoming/typing_start.rs index 032ba6433c5..a1d8ff90594 100644 --- a/twilight-model/src/gateway/payload/incoming/typing_start.rs +++ b/twilight-model/src/gateway/payload/incoming/typing_start.rs @@ -56,6 +56,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -119,7 +120,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -128,6 +129,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/gateway/payload/incoming/voice_state_update.rs b/twilight-model/src/gateway/payload/incoming/voice_state_update.rs index 9d74d98b7a1..afff69c7d53 100644 --- a/twilight-model/src/gateway/payload/incoming/voice_state_update.rs +++ b/twilight-model/src/gateway/payload/incoming/voice_state_update.rs @@ -58,6 +58,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 909, @@ -131,7 +132,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -139,6 +140,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -206,6 +209,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 4242, diff --git a/twilight-model/src/gateway/reaction.rs b/twilight-model/src/gateway/reaction.rs index 645a8894dd3..63b0e359c60 100644 --- a/twilight-model/src/gateway/reaction.rs +++ b/twilight-model/src/gateway/reaction.rs @@ -62,6 +62,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -135,7 +136,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -144,6 +145,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/ban.rs b/twilight-model/src/guild/ban.rs index 352c483deae..6ef221260bf 100644 --- a/twilight-model/src/guild/ban.rs +++ b/twilight-model/src/guild/ban.rs @@ -21,6 +21,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, diff --git a/twilight-model/src/guild/emoji.rs b/twilight-model/src/guild/emoji.rs index 1322c707d7c..7921e8ef9e0 100644 --- a/twilight-model/src/guild/emoji.rs +++ b/twilight-model/src/guild/emoji.rs @@ -49,6 +49,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -90,7 +91,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -98,6 +99,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -132,6 +135,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -178,7 +182,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -186,6 +190,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/integration.rs b/twilight-model/src/guild/integration.rs index 45a3a4e8c52..81f6f411123 100644 --- a/twilight-model/src/guild/integration.rs +++ b/twilight-model/src/guild/integration.rs @@ -99,6 +99,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: true, discriminator: 1000, @@ -178,7 +179,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -187,6 +188,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -247,6 +250,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: true, discriminator: 1000, @@ -341,7 +345,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -350,6 +354,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/integration_application.rs b/twilight-model/src/guild/integration_application.rs index f37cd4c8085..840dccb0bdb 100644 --- a/twilight-model/src/guild/integration_application.rs +++ b/twilight-model/src/guild/integration_application.rs @@ -60,6 +60,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -92,7 +93,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -100,6 +101,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/invite/mod.rs b/twilight-model/src/guild/invite/mod.rs index c62b099084d..b0d71acf778 100644 --- a/twilight-model/src/guild/invite/mod.rs +++ b/twilight-model/src/guild/invite/mod.rs @@ -197,6 +197,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -219,6 +220,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -355,7 +357,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -363,6 +365,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -391,7 +395,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -399,6 +403,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/member.rs b/twilight-model/src/guild/member.rs index e8a76fecf22..eae0717cf96 100644 --- a/twilight-model/src/guild/member.rs +++ b/twilight-model/src/guild/member.rs @@ -70,6 +70,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -122,7 +123,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -130,6 +131,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), @@ -153,6 +156,7 @@ mod tests { } #[test] + #[allow(clippy::too_many_lines)] fn guild_member_communication_disabled_until() -> Result<(), TimestampParseError> { let communication_disabled_until = Timestamp::from_str("2021-12-23T14:29:19.046000+00:00")?; let joined_at = Some(Timestamp::from_str("2015-04-26T06:26:56.936000+00:00")?); @@ -174,6 +178,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -227,7 +232,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -235,6 +240,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/guild/template/mod.rs b/twilight-model/src/guild/template/mod.rs index 6c082fddca6..0fe042a4f6c 100644 --- a/twilight-model/src/guild/template/mod.rs +++ b/twilight-model/src/guild/template/mod.rs @@ -183,6 +183,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: None, + avatar_decoration_data: None, banner: Some(image_hash::BANNER), bot: false, email: None, @@ -447,7 +448,7 @@ mod tests { Token::Str("creator"), Token::Struct { name: "User", - len: 10, + len: 11, }, Token::Str("accent_color"), Token::None, @@ -456,6 +457,8 @@ mod tests { Token::Str(image_hash::AVATAR_INPUT), Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::Some, Token::Str(image_hash::BANNER_INPUT), diff --git a/twilight-model/src/id/marker.rs b/twilight-model/src/id/marker.rs index 9b333908394..d121546c988 100644 --- a/twilight-model/src/id/marker.rs +++ b/twilight-model/src/id/marker.rs @@ -285,3 +285,12 @@ pub struct UserMarker; #[derive(Debug)] #[non_exhaustive] pub struct WebhookMarker; + +/// SKU ID marker for avatar decoration data. +/// +/// Types such as [`AvatarDecorationData`] use this ID marker. +/// +/// [`AvatarDecorationData`]: crate::user::AvatarDecorationData +#[derive(Debug)] +#[non_exhaustive] +pub struct AvatarDecorationDataSkuMarker; diff --git a/twilight-model/src/oauth/application.rs b/twilight-model/src/oauth/application.rs index 1d1067af35c..441ffc70011 100644 --- a/twilight-model/src/oauth/application.rs +++ b/twilight-model/src/oauth/application.rs @@ -134,6 +134,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -213,7 +214,7 @@ mod tests { Token::Some, Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -221,6 +222,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/oauth/team/member.rs b/twilight-model/src/oauth/team/member.rs index bc8f3c1c95d..28f0bdeec15 100644 --- a/twilight-model/src/oauth/team/member.rs +++ b/twilight-model/src/oauth/team/member.rs @@ -29,6 +29,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -65,7 +66,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -73,6 +74,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-model/src/user/avatar_decoration_data.rs b/twilight-model/src/user/avatar_decoration_data.rs new file mode 100644 index 00000000000..c502534ef69 --- /dev/null +++ b/twilight-model/src/user/avatar_decoration_data.rs @@ -0,0 +1,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, +} + +#[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, + ], + ); + } +} diff --git a/twilight-model/src/user/mod.rs b/twilight-model/src/user/mod.rs index c5e22e789be..45a4bd25758 100644 --- a/twilight-model/src/user/mod.rs +++ b/twilight-model/src/user/mod.rs @@ -1,3 +1,4 @@ +mod avatar_decoration_data; mod connection; mod connection_visibility; mod current_user; @@ -6,7 +7,8 @@ mod flags; mod premium_type; pub use self::{ - connection::Connection, connection_visibility::ConnectionVisibility, current_user::CurrentUser, + avatar_decoration_data::AvatarDecorationData, connection::Connection, + connection_visibility::ConnectionVisibility, current_user::CurrentUser, current_user_guild::CurrentUserGuild, flags::UserFlags, premium_type::PremiumType, }; @@ -125,6 +127,8 @@ pub struct User { pub avatar: Option, /// Hash of the user's avatar decoration. pub avatar_decoration: Option, + /// Data for the user's avatar decoration. + pub avatar_decoration_data: Option, /// Hash of the user's banner image. pub banner: Option, #[serde(default)] @@ -207,7 +211,7 @@ mod tests { vec![ Token::Struct { name: "User", - len: 16, + len: 17, }, Token::Str("accent_color"), Token::None, @@ -217,6 +221,8 @@ mod tests { Token::Str("avatar_decoration"), Token::Some, Token::Str(image_hash::AVATAR_DECORATION_INPUT), + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::Some, Token::Str(image_hash::BANNER_INPUT), @@ -261,7 +267,7 @@ mod tests { vec![ Token::Struct { name: "User", - len: 17, + len: 18, }, Token::Str("accent_color"), Token::None, @@ -271,6 +277,8 @@ mod tests { Token::Str("avatar_decoration"), Token::Some, Token::Str(image_hash::AVATAR_DECORATION_INPUT), + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::Some, Token::Str(image_hash::BANNER_INPUT), @@ -330,6 +338,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: Some(image_hash::AVATAR_DECORATION), + avatar_decoration_data: None, banner: Some(image_hash::BANNER), bot: false, discriminator: 1, @@ -362,6 +371,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: Some(image_hash::AVATAR_DECORATION), + avatar_decoration_data: None, banner: Some(image_hash::BANNER), bot: false, discriminator: 0, @@ -391,6 +401,7 @@ mod tests { accent_color: None, avatar: Some(image_hash::AVATAR), avatar_decoration: Some(image_hash::AVATAR_DECORATION), + avatar_decoration_data: None, banner: Some(image_hash::BANNER), bot: false, discriminator: 1, diff --git a/twilight-model/src/voice/voice_state.rs b/twilight-model/src/voice/voice_state.rs index ec22d3da16c..a15aa28e003 100644 --- a/twilight-model/src/voice/voice_state.rs +++ b/twilight-model/src/voice/voice_state.rs @@ -152,6 +152,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -227,7 +228,7 @@ mod tests { Token::Str("user"), Token::Struct { name: "User", - len: 9, + len: 10, }, Token::Str("accent_color"), Token::None, @@ -235,6 +236,8 @@ mod tests { Token::None, Token::Str("avatar_decoration"), Token::None, + Token::Str("avatar_decoration_data"), + Token::None, Token::Str("banner"), Token::None, Token::Str("bot"), diff --git a/twilight-standby/src/lib.rs b/twilight-standby/src/lib.rs index 2d882aacc85..5e0104e19e3 100644 --- a/twilight-standby/src/lib.rs +++ b/twilight-standby/src/lib.rs @@ -1092,6 +1092,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1, @@ -1212,6 +1213,7 @@ mod tests { accent_color: None, avatar: None, avatar_decoration: None, + avatar_decoration_data: None, banner: None, bot: false, discriminator: 1,