Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pubsub): implement Clone and Hash for topics #181

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<&str>>` as the `auth_token`.
* `pubsub::Topics` and all topics now implement `Clone` and `Hash`.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/automod_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_bits_badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_cheer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_sub_gifts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/channel_subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/community_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/following.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/hypetrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub trait Topic: Serialize + Into<String> {
}

/// All possible topics
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug)]
#[derive(Deserialize, Serialize, PartialEq, Eq, Debug, Clone, Hash)]
#[serde(untagged)]
#[non_exhaustive]
pub enum Topics {
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/moderation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/raid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/pubsub/user_moderation_notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/pubsub/video_playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down