From 9ec625e684e91c80f302fc1f90b4ac3cffb46a94 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Tue, 27 Jul 2021 11:51:19 +0200 Subject: [PATCH 1/3] feat(pubsub): derive `Clone` for `Topics` --- src/pubsub/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pubsub/mod.rs b/src/pubsub/mod.rs index b5d69565fd..c6fba9b0ae 100644 --- a/src/pubsub/mod.rs +++ b/src/pubsub/mod.rs @@ -133,7 +133,7 @@ pub trait Topic: Serialize + Into { } /// All possible topics -#[derive(Deserialize, Serialize, PartialEq, Eq, Debug)] +#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)] #[serde(untagged)] #[non_exhaustive] pub enum Topics { From 476b98f5314fc3d504c9e9fe7a0d8dd055228173 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Tue, 27 Jul 2021 12:01:46 +0200 Subject: [PATCH 2/3] feat(pubsub): derive `Hash` for `Topics` --- src/pubsub/automod_queue.rs | 2 +- src/pubsub/channel_bits.rs | 2 +- src/pubsub/channel_bits_badge.rs | 2 +- src/pubsub/channel_cheer.rs | 2 +- src/pubsub/channel_points.rs | 2 +- src/pubsub/channel_sub_gifts.rs | 2 +- src/pubsub/channel_subscriptions.rs | 2 +- src/pubsub/community_points.rs | 2 +- src/pubsub/following.rs | 2 +- src/pubsub/hypetrain.rs | 4 ++-- src/pubsub/mod.rs | 2 +- src/pubsub/moderation.rs | 2 +- src/pubsub/raid.rs | 2 +- src/pubsub/user_moderation_notifications.rs | 2 +- src/pubsub/video_playback.rs | 4 ++-- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/pubsub/automod_queue.rs b/src/pubsub/automod_queue.rs index 9b3eafc1d5..d479a83e24 100644 --- a/src/pubsub/automod_queue.rs +++ b/src/pubsub/automod_queue.rs @@ -3,7 +3,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user follows the channel -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct AutoModQueue { /// The currently authenticated moderator diff --git a/src/pubsub/channel_bits.rs b/src/pubsub/channel_bits.rs index 51533158dc..3ccdb6b8cd 100644 --- a/src/pubsub/channel_bits.rs +++ b/src/pubsub/channel_bits.rs @@ -5,7 +5,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// Anyone cheers in a specified channel. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelBitsEventsV2 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/channel_bits_badge.rs b/src/pubsub/channel_bits_badge.rs index 2d58721eea..585d46ce5c 100644 --- a/src/pubsub/channel_bits_badge.rs +++ b/src/pubsub/channel_bits_badge.rs @@ -4,7 +4,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// Anyone shares a bit badge in a specified channel. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelBitsBadgeUnlocks { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/channel_cheer.rs b/src/pubsub/channel_cheer.rs index 3b8bae5141..f842e56c74 100644 --- a/src/pubsub/channel_cheer.rs +++ b/src/pubsub/channel_cheer.rs @@ -5,7 +5,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user redeems a cheer with shared rewards. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelCheerEventsPublicV1 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/channel_points.rs b/src/pubsub/channel_points.rs index 4add597503..bf6c08eb17 100644 --- a/src/pubsub/channel_points.rs +++ b/src/pubsub/channel_points.rs @@ -5,7 +5,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user redeems an reward using channel points. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelPointsChannelV1 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/channel_sub_gifts.rs b/src/pubsub/channel_sub_gifts.rs index 91c1716086..f95b19d11c 100644 --- a/src/pubsub/channel_sub_gifts.rs +++ b/src/pubsub/channel_sub_gifts.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; /// A user gifts subs. /// /// This allows one to know how many subs were gifted in a single event. See also [`pubsub::channel_subscriptions::ChannelSubscribeEventsV1`] which needs token from broadcaster -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelSubGiftsV1 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/channel_subscriptions.rs b/src/pubsub/channel_subscriptions.rs index 634c416dbc..aaec9da79d 100644 --- a/src/pubsub/channel_subscriptions.rs +++ b/src/pubsub/channel_subscriptions.rs @@ -6,7 +6,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A subscription event happens in channel -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChannelSubscribeEventsV1 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/community_points.rs b/src/pubsub/community_points.rs index 2c01b8efed..3f7a729690 100644 --- a/src/pubsub/community_points.rs +++ b/src/pubsub/community_points.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; /// A user redeems an reward using channel points. /// /// Reply is [`pubsub::channel_points::ChannelPointsChannelV1Reply`] -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct CommunityPointsChannelV1 { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/following.rs b/src/pubsub/following.rs index 4733476b94..02a9ce6c83 100644 --- a/src/pubsub/following.rs +++ b/src/pubsub/following.rs @@ -5,7 +5,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user follows the channel -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct Following { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/hypetrain.rs b/src/pubsub/hypetrain.rs index beae2c5db7..2815b08a45 100644 --- a/src/pubsub/hypetrain.rs +++ b/src/pubsub/hypetrain.rs @@ -4,7 +4,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user redeems an reward using channel points. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))] #[serde(into = "String", try_from = "String")] pub struct HypeTrainEventsV1 { @@ -26,7 +26,7 @@ impl pubsub::Topic for HypeTrainEventsV1 { } /// A user redeems an reward using channel points. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))] #[serde(into = "String", try_from = "String")] pub struct HypeTrainEventsV1Rewards { diff --git a/src/pubsub/mod.rs b/src/pubsub/mod.rs index c6fba9b0ae..3231c8d653 100644 --- a/src/pubsub/mod.rs +++ b/src/pubsub/mod.rs @@ -133,7 +133,7 @@ pub trait Topic: Serialize + Into { } /// All possible topics -#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone)] +#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone, Hash)] #[serde(untagged)] #[non_exhaustive] pub enum Topics { diff --git a/src/pubsub/moderation.rs b/src/pubsub/moderation.rs index 35a7b6fa1b..7952acc627 100644 --- a/src/pubsub/moderation.rs +++ b/src/pubsub/moderation.rs @@ -6,7 +6,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A moderator performs an action in the channel. -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(into = "String", try_from = "String")] pub struct ChatModeratorActions { /// The user_id to listen as. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/raid.rs b/src/pubsub/raid.rs index 00863f1d03..f87d840e16 100644 --- a/src/pubsub/raid.rs +++ b/src/pubsub/raid.rs @@ -4,7 +4,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user raids the channel -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct Raid { /// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint diff --git a/src/pubsub/user_moderation_notifications.rs b/src/pubsub/user_moderation_notifications.rs index 0fb55b7ff7..a59aa5b97d 100644 --- a/src/pubsub/user_moderation_notifications.rs +++ b/src/pubsub/user_moderation_notifications.rs @@ -3,7 +3,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// A user follows the channel -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] #[serde(into = "String", try_from = "String")] pub struct UserModerationNotifications { /// The currently authenticated user for whose automod messages will be reported on diff --git a/src/pubsub/video_playback.rs b/src/pubsub/video_playback.rs index 687d8ec6e0..d2aa62f6c6 100644 --- a/src/pubsub/video_playback.rs +++ b/src/pubsub/video_playback.rs @@ -9,7 +9,7 @@ use crate::{pubsub, types}; use serde::{Deserialize, Serialize}; /// Statistics about stream -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(into = "String", try_from = "String")] pub struct VideoPlayback { /// The channel_login to watch. @@ -26,7 +26,7 @@ impl pubsub::Topic for VideoPlayback { } /// Statistics about stream -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)] #[serde(into = "String", try_from = "String")] pub struct VideoPlaybackById { /// The channel_login to watch. From 7b12ee4fc5c41f146c53404a3eb83f18d618348a Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Tue, 27 Jul 2021 12:04:21 +0200 Subject: [PATCH 3/3] docs: update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc8cd7ae91..a935d44030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ * Renamed `BroadcasterType::Affiliated` -> `BroadcasterType::Affiliate` * Client extension methods that are paginated are now paginated lazily using a stream. * `pubsub::listen_command` now accepts `Into>` as the `auth_token`. +* `pubsub::Topics` and all topics now implement `Clone` and `Hash`. ### Removed