You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
260: feat: provide `to_str` and `FromStr` for EventType r=Nerixyz a=Nerixyz
To check the `Twitch-Eventsub-Subscription-Type` header, I need to compare it to the `EventType`. When creating a guard for an eventsub route, the `EventType` is already known, so the guard should just compare strings/bytes. However, the only way of getting the string representation is through `impl Display`, which allocates. That's why I'm adding `to_str` (which is marked as const so rustc hopefully computes the output at compile time in generic functions).
When adding `to_str` we might as well add `FromStr`, where I didn't really have an idea about the error type, so it's like an `Option` now.
Since the implementations for `to_str` and `FromStr` require a lot of repeating code, I created a macro that implements the whole type.
The type wasn't marked as `Copy`, so I marked it as `Copy` since it's really just an integer in the end.
Co-authored-by: Nerixyz <[email protected]>
/// `channel.update` subscription type sends notifications when a broadcaster updates the category, title, mature flag, or broadcast language for their channel.
61
-
#[serde(rename = "channel.update")]
62
-
ChannelUpdate,
63
-
/// `channel.follow`: a specified channel receives a follow.
64
-
#[serde(rename = "channel.follow")]
65
-
ChannelFollow,
66
-
/// `channel.subscribe`: a specified channel receives a subscriber. This does not include resubscribes.
67
-
#[serde(rename = "channel.subscribe")]
68
-
ChannelSubscribe,
69
-
/// `channel.cheer`: a user cheers on the specified channel.
70
-
#[serde(rename = "channel.cheer")]
71
-
ChannelCheer,
72
-
/// `channel.ban`: a viewer is banned from the specified channel.
73
-
#[serde(rename = "channel.ban")]
74
-
ChannelBan,
75
-
/// `channel.unban`: a viewer is unbanned from the specified channel.
76
-
#[serde(rename = "channel.unban")]
77
-
ChannelUnban,
78
-
/// `channel.channel_points_custom_reward.add`: a custom channel points reward has been created for the specified channel.
/// `channel.channel_points_custom_reward_redemption.update`: a redemption of a channel points custom reward has been updated for the specified channel.
/// `channel.poll.begin`: a poll begins on the specified channel.
94
-
#[serde(rename = "channel.poll.begin")]
95
-
ChannelPollBegin,
96
-
/// `channel.poll.progress`: a user responds to a poll on the specified channel.
97
-
#[serde(rename = "channel.poll.progress")]
98
-
ChannelPollProgress,
99
-
/// `channel.poll.end`: a poll ends on the specified channel.
100
-
#[serde(rename = "channel.poll.end")]
101
-
ChannelPollEnd,
102
-
/// `channel.prediction.begin`: a Prediction begins on the specified channel
103
-
#[serde(rename = "channel.prediction.begin")]
104
-
ChannelPredictionBegin,
105
-
/// `channel.prediction.progress`: a user participates in a Prediction on the specified channel.
106
-
#[serde(rename = "channel.prediction.progress")]
107
-
ChannelPredictionProgress,
108
-
/// `channel.prediction.lock`: a Prediction is locked on the specified channel.
109
-
#[serde(rename = "channel.prediction.lock")]
110
-
ChannelPredictionLock,
111
-
/// `channel.prediction.end`: a Prediction ends on the specified channel.
112
-
#[serde(rename = "channel.prediction.end")]
113
-
ChannelPredictionEnd,
114
-
/// `channel.raid`: a broadcaster raids another broadcaster’s channel.
115
-
#[serde(rename = "channel.raid")]
116
-
ChannelRaid,
117
-
/// `channel.subscription.end`: a subscription to the specified channel expires.
118
-
#[serde(rename = "channel.subscription.end")]
119
-
ChannelSubscriptionEnd,
120
-
/// `channel.subscription.gift`: a user gives one or more gifted subscriptions in a channel.
121
-
#[serde(rename = "channel.subscription.gift")]
122
-
ChannelSubscriptionGift,
123
-
/// `channel.subscription.gift`: a user sends a resubscription chat message in a specific channel
124
-
#[serde(rename = "channel.subscription.message")]
125
-
ChannelSubscriptionMessage,
126
-
/// `channel.goal.begin`: a goal begins on the specified channel.
127
-
#[serde(rename = "channel.goal.begin")]
128
-
ChannelGoalBegin,
129
-
/// `channel.goal.progress`: a goal makes progress on the specified channel.
130
-
#[serde(rename = "channel.goal.progress")]
131
-
ChannelGoalProgress,
132
-
/// `channel.goal.end`: a goal ends on the specified channel.
133
-
#[serde(rename = "channel.goal.end")]
134
-
ChannelGoalEnd,
135
-
/// `channel.hype_train.begin`: a hype train begins on the specified channel.
136
-
#[serde(rename = "channel.hype_train.begin")]
137
-
ChannelHypeTrainBegin,
138
-
/// `channel.hype_train.progress`: a hype train makes progress on the specified channel.
139
-
#[serde(rename = "channel.hype_train.progress")]
140
-
ChannelHypeTrainProgress,
141
-
/// `channel.hype_train.end`: a hype train ends on the specified channel.
142
-
#[serde(rename = "channel.hype_train.end")]
143
-
ChannelHypeTrainEnd,
144
-
/// `stream.online`: the specified broadcaster starts a stream.
145
-
#[serde(rename = "stream.online")]
146
-
StreamOnline,
147
-
/// `stream.online`: the specified broadcaster stops a stream.
148
-
#[serde(rename = "stream.offline")]
149
-
StreamOffline,
150
-
/// `user.update`: user updates their account.
151
-
#[serde(rename = "user.update")]
152
-
UserUpdate,
153
-
/// `user.authorization.revoke`: a user has revoked authorization for your client id. Use this webhook to meet government requirements for handling user data, such as GDPR, LGPD, or CCPA.
154
-
#[serde(rename = "user.authorization.revoke")]
155
-
UserAuthorizationRevoke,
156
-
/// `user.authorization.revoke`: a user’s authorization has been granted to your client id.
"a user has revoked authorization for your client id. Use this webhook to meet government requirements for handling user data, such as GDPR, LGPD, or CCPA.":
0 commit comments