Skip to content

Commit d745b05

Browse files
Merge #82
82: make errors on unknown fields opt-in instead of opt-out r=Emilgardis a=Emilgardis Co-authored-by: Emil Gardström <emil.gardstrom@gmail.com>
2 parents e0a7fcb + deb503a commit d745b05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+144
-152
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22
env:
3-
CI_TWITCH_API2_FEATURES: "twitch_oauth2/all all unsupported"
3+
CI_TWITCH_API2_FEATURES: "twitch_oauth2/all all unsupported deny_unknown_fields"
44
on:
55
pull_request:
66
types: [opened, reopened, synchronize]

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: github pages
22
env:
3-
CI_TWITCH_API2_FEATURES: "twitch_oauth2/all all unsupported"
3+
CI_TWITCH_API2_FEATURES: "twitch_oauth2/all all unsupported deny_unknown_fields"
44
RUSTDOCFLAGS: "-Z unstable-options --html-in-header=docs/pre-content.html"
55
on:
66
push:

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"rust-analyzer.checkOnSave.allTargets": false,
3-
"rust-analyzer.checkOnSave.features": ["all", "unsupported", "twitch_oauth2/reqwest_client", "twitch_oauth2/surf_client"],
3+
"rust-analyzer.checkOnSave.features": ["all", "unsupported", "twitch_oauth2/reqwest_client", "twitch_oauth2/surf_client", "deny_unknown_fields"],
44
"rust-analyzer.checkOnSave.enable": true,
5-
"rust-analyzer.cargo.features": ["all", "unsupported"],
5+
"rust-analyzer.cargo.features": ["all", "unsupported", "deny_unknown_fields"],
66
}

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
* Made crate runtime agnostic with custom clients using feature `client`.
1212
* Added `unsupported` feature to enable experimental/undocumented APIs/endpoints/topics.
13-
* Made most fields deny unknown fields by default, specify feature `allow_unknown_fields` to ignore unknowns.
14-
* Added `all` feature to enable all feature sans `unsupported` and `allow_unknown_fields`.
13+
* Made most fields deny unknown fields by enabling feature `deny_unknown_fields`.
14+
* Added `all` feature to enable all feature sans `unsupported` and `deny_unknown_fields`.
1515
* Added most PubSub topics.
1616
- channel-bits-events-v2
1717
- channel-bits-badge-unlocks

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ default = []
3535
client = ["twitch_oauth2"]
3636

3737
unsupported = []
38-
allow_unknown_fields = []
38+
deny_unknown_fields = []
3939

4040
helix = [
4141
"url",

src/eventsub/channel/ban.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::*;
44

55
/// [`channel.ban`](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelban): a viewer is banned from the specified channel.
66
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
7+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
88
#[non_exhaustive]
99
pub struct ChannelBanV1 {
1010
/// The broadcaster user ID for the channel you want to get ban notifications for.
@@ -22,7 +22,7 @@ impl EventSubscription for ChannelBanV1 {
2222

2323
/// [`channel.ban`](ChannelBanV1) response payload.
2424
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
25-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
25+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
2626
#[non_exhaustive]
2727
pub struct ChannelBanV1Payload {
2828
/// The user ID for the user who was banned on the specified channel.

src/eventsub/channel/channel_points_custom_reward/add.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use super::*;
55
/// [`channel.channel_points_custom_reward.add`](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelchannel_points_custom_rewardadd): a custom channel points reward has been created for the specified channel.
66
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
7+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
88
#[non_exhaustive]
99
pub struct ChannelPointsCustomRewardAddV1 {
1010
/// The broadcaster user ID for the channel you want to receive channel points custom reward add notifications for.
@@ -23,7 +23,7 @@ impl EventSubscription for ChannelPointsCustomRewardAddV1 {
2323
// FIXME: Same as update
2424
/// [`channel.channel_points_custom_reward.add`](ChannelPointsCustomRewardAddV1) response payload.
2525
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
26-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
26+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
2727
#[non_exhaustive]
2828
pub struct ChannelPointsCustomRewardAddV1Payload {
2929
/// Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2.

src/eventsub/channel/channel_points_custom_reward/remove.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use super::*;
55
/// [`channel.channel_points_custom_reward.remove`](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelchannel_points_custom_rewardremove): a custom channel points reward has been removed from the specified channel.
66
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
7+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
88
#[non_exhaustive]
99
pub struct ChannelPointsCustomRewardRemoveV1 {
1010
/// The broadcaster user ID for the channel you want to receive channel points custom reward remove notifications for.
@@ -24,7 +24,7 @@ impl EventSubscription for ChannelPointsCustomRewardRemoveV1 {
2424

2525
/// [`channel.channel_points_custom_reward.remove`](ChannelPointsCustomRewardRemoveV1) response payload.
2626
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
27-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
27+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
2828
#[non_exhaustive]
2929
pub struct ChannelPointsCustomRewardRemoveV1Payload {
3030
/// Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2.

src/eventsub/channel/channel_points_custom_reward/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use super::*;
55
/// [`channel.channel_points_custom_reward.update`](https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelchannel_points_custom_rewardupdate): a custom channel points reward has been updated for the specified channel.
66
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
7-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
7+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
88
#[non_exhaustive]
99
pub struct ChannelPointsCustomRewardUpdateV1 {
1010
/// The broadcaster user ID for the channel you want to receive channel points custom reward update notifications for.
@@ -24,7 +24,7 @@ impl EventSubscription for ChannelPointsCustomRewardUpdateV1 {
2424

2525
/// [`channel.channel_points_custom_reward.update`](ChannelPointsCustomRewardUpdateV1) response payload.
2626
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
27-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
27+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
2828
#[non_exhaustive]
2929
pub struct ChannelPointsCustomRewardUpdateV1Payload {
3030
/// Custom background color for the reward. Format: Hex with # prefix. Example: #FA1ED2.

src/eventsub/channel/channel_points_custom_reward_redemption.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use update::{
1919

2020
/// Basic information about the reward that was redeemed, at the time it was redeemed.
2121
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
22-
#[cfg_attr(not(feature = "allow_unknown_fields"), serde(deny_unknown_fields))]
22+
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
2323
#[non_exhaustive]
2424
pub struct Reward {
2525
/// The reward cost.

0 commit comments

Comments
 (0)