Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities
This commit is contained in:
parent
1c4ff11b35
commit
a8b747f1ef
|
@ -225,7 +225,7 @@ pub struct ApplicationCommandOptionChoice {
|
|||
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
/// # Reference
|
||||
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types>
|
||||
pub enum ApplicationCommandOptionType {
|
||||
|
@ -296,7 +296,7 @@ pub struct ApplicationCommandPermission {
|
|||
)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type>
|
||||
pub enum ApplicationCommandPermissionType {
|
||||
#[default]
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct AutoModerationRule {
|
|||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types>
|
||||
pub enum AutoModerationRuleEventType {
|
||||
|
@ -45,7 +45,7 @@ pub enum AutoModerationRuleEventType {
|
|||
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types>
|
||||
pub enum AutoModerationRuleTriggerType {
|
||||
|
@ -97,7 +97,7 @@ pub struct AutoModerationRuleTriggerMetadataForMentionSpam {
|
|||
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types>
|
||||
pub enum AutoModerationRuleKeywordPresetType {
|
||||
|
@ -129,7 +129,7 @@ pub struct AutoModerationAction {
|
|||
Hash,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types>
|
||||
pub enum AutoModerationActionType {
|
||||
|
|
|
@ -304,7 +304,7 @@ impl PartialEq for GuildScheduledEvent {
|
|||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level>
|
||||
pub enum GuildScheduledEventPrivacyLevel {
|
||||
#[default]
|
||||
|
@ -313,7 +313,7 @@ pub enum GuildScheduledEventPrivacyLevel {
|
|||
|
||||
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status>
|
||||
pub enum GuildScheduledEventStatus {
|
||||
#[default]
|
||||
|
@ -337,7 +337,7 @@ pub enum GuildScheduledEventStatus {
|
|||
Hash,
|
||||
)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types>
|
||||
pub enum GuildScheduledEventEntityType {
|
||||
#[default]
|
||||
|
@ -400,7 +400,7 @@ pub enum MessageNotificationLevel {
|
|||
)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/guild#explicit-content-filter-level>
|
||||
pub enum ExplicitContentFilterLevel {
|
||||
|
@ -425,7 +425,7 @@ pub enum ExplicitContentFilterLevel {
|
|||
)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
|
||||
pub enum VerificationLevel {
|
||||
|
@ -452,7 +452,7 @@ pub enum VerificationLevel {
|
|||
)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
|
||||
pub enum MFALevel {
|
||||
|
@ -476,7 +476,7 @@ pub enum MFALevel {
|
|||
)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
|
||||
pub enum NSFWLevel {
|
||||
|
@ -502,7 +502,7 @@ pub enum NSFWLevel {
|
|||
)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
|
||||
pub enum PremiumTier {
|
||||
|
|
|
@ -42,7 +42,10 @@ pub enum UserTheme {
|
|||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||
pub struct UserSettings {
|
||||
#[cfg(not(feature = "sqlx"))]
|
||||
pub afk_timeout: Option<u16>,
|
||||
#[cfg(feature = "sqlx")]
|
||||
pub afk_timeout: Option<sqlx_pg_uint::PgU16>,
|
||||
pub allow_accessibility_detection: bool,
|
||||
pub animate_emoji: bool,
|
||||
#[cfg(not(feature = "sqlx"))]
|
||||
|
@ -85,7 +88,7 @@ pub struct UserSettings {
|
|||
impl Default for UserSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
afk_timeout: Some(3600),
|
||||
afk_timeout: Some(3600.into()),
|
||||
allow_accessibility_detection: true,
|
||||
animate_emoji: true,
|
||||
#[cfg(not(feature = "sqlx"))]
|
||||
|
@ -137,6 +140,7 @@ pub struct CustomStatus {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||
pub struct FriendSourceFlags {
|
||||
pub all: bool,
|
||||
}
|
||||
|
@ -148,6 +152,7 @@ impl Default for FriendSourceFlags {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
|
||||
pub struct GuildFolder {
|
||||
#[cfg(not(feature = "sqlx"))]
|
||||
pub color: Option<u32>,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use bitflags::bitflags;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::types::{ChannelType, DefaultReaction, entities::PermissionOverwrite, Snowflake};
|
||||
use crate::types::{entities::PermissionOverwrite, ChannelType, DefaultReaction, Snowflake};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Default, PartialEq, PartialOrd)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
@ -141,7 +141,8 @@ bitflags! {
|
|||
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
pub enum InviteType {
|
||||
#[default]
|
||||
Guild = 0,
|
||||
|
@ -152,7 +153,8 @@ pub enum InviteType {
|
|||
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
|
||||
#[cfg_attr(feature = "sqlx", repr(i16))]
|
||||
pub enum InviteTargetType {
|
||||
#[default]
|
||||
Stream = 1,
|
||||
|
@ -169,7 +171,9 @@ pub struct AddChannelRecipientSchema {
|
|||
}
|
||||
|
||||
/// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient>
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash)]
|
||||
#[derive(
|
||||
Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash,
|
||||
)]
|
||||
pub struct ModifyChannelPositionsSchema {
|
||||
pub id: Snowflake,
|
||||
pub position: Option<u32>,
|
||||
|
@ -178,7 +182,9 @@ pub struct ModifyChannelPositionsSchema {
|
|||
}
|
||||
|
||||
/// See <https://docs.discord.sex/resources/channel#follow-channel>
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash)]
|
||||
#[derive(
|
||||
Debug, Deserialize, Serialize, Clone, Default, PartialOrd, Ord, PartialEq, Eq, Copy, Hash,
|
||||
)]
|
||||
pub struct AddFollowingChannelSchema {
|
||||
pub webhook_channel_id: Snowflake,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue