Skip to content

Commit 1b6d1b9

Browse files
bors[bot]Nerixyz
andauthored
Merge #181
181: feat(pubsub): implement `Clone` and `Hash` for topics r=Emilgardis a=Nerixyz This PR implements * `Clone` for the `Topics` enum (all subtopics already implement `Clone`) * `Hash` for all topics Co-authored-by: Nerixyz <[email protected]>
2 parents 3996759 + 7b12ee4 commit 1b6d1b9

16 files changed

+18
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* Renamed `BroadcasterType::Affiliated` -> `BroadcasterType::Affiliate`
4545
* Client extension methods that are paginated are now paginated lazily using a stream.
4646
* `pubsub::listen_command` now accepts `Into<Option<&str>>` as the `auth_token`.
47+
* `pubsub::Topics` and all topics now implement `Clone` and `Hash`.
4748

4849
### Removed
4950

src/pubsub/automod_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{pubsub, types};
33
use serde::{Deserialize, Serialize};
44

55
/// A user follows the channel
6-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
77
#[serde(into = "String", try_from = "String")]
88
pub struct AutoModQueue {
99
/// The currently authenticated moderator

src/pubsub/channel_bits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{pubsub, types};
55
use serde::{Deserialize, Serialize};
66

77
/// Anyone cheers in a specified channel.
8-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
8+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
99
#[serde(into = "String", try_from = "String")]
1010
pub struct ChannelBitsEventsV2 {
1111
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/channel_bits_badge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{pubsub, types};
44
use serde::{Deserialize, Serialize};
55

66
/// Anyone shares a bit badge in a specified channel.
7-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
88
#[serde(into = "String", try_from = "String")]
99
pub struct ChannelBitsBadgeUnlocks {
1010
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/channel_cheer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{pubsub, types};
55
use serde::{Deserialize, Serialize};
66

77
/// A user redeems a cheer with shared rewards.
8-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
99
#[serde(into = "String", try_from = "String")]
1010
pub struct ChannelCheerEventsPublicV1 {
1111
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/channel_points.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{pubsub, types};
55
use serde::{Deserialize, Serialize};
66

77
/// A user redeems an reward using channel points.
8-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
99
#[serde(into = "String", try_from = "String")]
1010
pub struct ChannelPointsChannelV1 {
1111
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/channel_sub_gifts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
77
/// A user gifts subs.
88
///
99
/// 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
10-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
10+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
1111
#[serde(into = "String", try_from = "String")]
1212
pub struct ChannelSubGiftsV1 {
1313
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/channel_subscriptions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{pubsub, types};
66
use serde::{Deserialize, Serialize};
77

88
/// A subscription event happens in channel
9-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
9+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
1010
#[serde(into = "String", try_from = "String")]
1111
pub struct ChannelSubscribeEventsV1 {
1212
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/community_points.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
88
/// A user redeems an reward using channel points.
99
///
1010
/// Reply is [`pubsub::channel_points::ChannelPointsChannelV1Reply`]
11-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
11+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
1212
#[serde(into = "String", try_from = "String")]
1313
pub struct CommunityPointsChannelV1 {
1414
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/following.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{pubsub, types};
55
use serde::{Deserialize, Serialize};
66

77
/// A user follows the channel
8-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
99
#[serde(into = "String", try_from = "String")]
1010
pub struct Following {
1111
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/hypetrain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{pubsub, types};
44
use serde::{Deserialize, Serialize};
55

66
/// A user redeems an reward using channel points.
7-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
7+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
88
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
99
#[serde(into = "String", try_from = "String")]
1010
pub struct HypeTrainEventsV1 {
@@ -26,7 +26,7 @@ impl pubsub::Topic for HypeTrainEventsV1 {
2626
}
2727

2828
/// A user redeems an reward using channel points.
29-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
29+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
3030
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
3131
#[serde(into = "String", try_from = "String")]
3232
pub struct HypeTrainEventsV1Rewards {

src/pubsub/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub trait Topic: Serialize + Into<String> {
133133
}
134134

135135
/// All possible topics
136-
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug)]
136+
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone, Hash)]
137137
#[serde(untagged)]
138138
#[non_exhaustive]
139139
pub enum Topics {

src/pubsub/moderation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{pubsub, types};
66
use serde::{Deserialize, Serialize};
77

88
/// A moderator performs an action in the channel.
9-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
9+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
1010
#[serde(into = "String", try_from = "String")]
1111
pub struct ChatModeratorActions {
1212
/// The user_id to listen as. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/raid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{pubsub, types};
44
use serde::{Deserialize, Serialize};
55

66
/// A user raids the channel
7-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
7+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
88
#[serde(into = "String", try_from = "String")]
99
pub struct Raid {
1010
/// The channel_id to watch. Can be fetched with the [Get Users](crate::helix::users::get_users) endpoint

src/pubsub/user_moderation_notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{pubsub, types};
33
use serde::{Deserialize, Serialize};
44

55
/// A user follows the channel
6-
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
77
#[serde(into = "String", try_from = "String")]
88
pub struct UserModerationNotifications {
99
/// The currently authenticated user for whose automod messages will be reported on

src/pubsub/video_playback.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{pubsub, types};
99
use serde::{Deserialize, Serialize};
1010

1111
/// Statistics about stream
12-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
12+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
1313
#[serde(into = "String", try_from = "String")]
1414
pub struct VideoPlayback {
1515
/// The channel_login to watch.
@@ -26,7 +26,7 @@ impl pubsub::Topic for VideoPlayback {
2626
}
2727

2828
/// Statistics about stream
29-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
29+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
3030
#[serde(into = "String", try_from = "String")]
3131
pub struct VideoPlaybackById {
3232
/// The channel_login to watch.

0 commit comments

Comments
 (0)