Skip to content

Commit

Permalink
Unify derive & #[non_exhaustive] attributes for number enums (ser…
Browse files Browse the repository at this point in the history
…enity-rs#1999)

BREAKING CHANGE: Some enums were missing the `[non_exhaustive]` attribute.
  • Loading branch information
nickelc authored and mkrasnitski committed Oct 24, 2023
1 parent 2f645d9 commit 795f6c5
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/model/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ pub struct TeamMember {
}

/// [Discord docs](https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum).
#[derive(Clone, Debug, Copy, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum MembershipState {
Invited = 1,
Accepted = 2,
Expand Down
6 changes: 3 additions & 3 deletions src/model/application/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Command {
/// The type of an application command.
///
/// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum CommandType {
Expand Down Expand Up @@ -335,7 +335,7 @@ pub struct CommandOption {
/// The type of an [`CommandOption`].
///
/// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-type).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum CommandOptionType {
Expand Down Expand Up @@ -416,7 +416,7 @@ pub struct CommandPermissionData {
/// The type of an [`CommandPermissionData`].
///
/// [Discord docs](https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum CommandPermissionType {
Expand Down
6 changes: 3 additions & 3 deletions src/model/application/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::model::channel::ReactionType;
use crate::model::utils::deserialize_val;

/// The type of a component
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum ComponentType {
Expand Down Expand Up @@ -105,7 +105,7 @@ pub struct Button {
}

/// The style of a button.
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum ButtonStyle {
Expand Down Expand Up @@ -176,7 +176,7 @@ pub struct InputText {
}

/// The style of the input text
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum InputTextStyle {
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl Serialize for Interaction {
/// The type of an Interaction.
///
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-type).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum InteractionType {
Expand Down
2 changes: 1 addition & 1 deletion src/model/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Connection {
/// The visibility of a user connection on a user's profile.
///
/// [Discord docs](https://discord.com/developers/docs/resources/user#connection-object-visibility-types).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum ConnectionVisibility {
Expand Down
2 changes: 1 addition & 1 deletion src/model/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pub struct ActivityEmoji {
}

/// [Discord docs](https://discord.com/developers/docs/topics/gateway#activity-object-activity-types).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum ActivityType {
/// An indicator that the user is playing a game.
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Integration {
/// The behavior once the integration expires.
///
/// [Discord docs](https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors).
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
#[repr(u8)]
pub enum IntegrationExpireBehaviour {
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/premium_tier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// The guild's premium tier, depends on the amount of users boosting the guild currently
///
/// [Discord docs](https://discord.com/developers/docs/resources/guild#guild-object-premium-tier).
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum PremiumTier {
/// No tier, considered None
Expand Down
6 changes: 4 additions & 2 deletions src/model/guild/scheduled_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ pub struct ScheduledEvent {
}

/// [Discord docs](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status).
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum ScheduledEventStatus {
Scheduled = 1,
Active = 2,
Expand All @@ -66,7 +67,8 @@ enum_number!(ScheduledEventStatus {
});

/// [Discord docs](https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types).
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum ScheduledEventType {
StageInstance = 1,
Voice = 2,
Expand Down

0 comments on commit 795f6c5

Please sign in to comment.