From ce67efe93cf5fa31edcf85c555c1fdbd7bdf2863 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Sun, 18 Aug 2024 22:38:07 +0200 Subject: [PATCH] swap u64 for PgU64 in some files --- src/types/entities/attachment.rs | 16 +++++++++++++++- src/types/entities/audit_log.rs | 14 ++++++++++++++ src/types/entities/channel.rs | 3 +++ src/types/entities/guild.rs | 3 +++ src/types/entities/security_key.rs | 6 ++++++ src/types/entities/template.rs | 5 ++++- 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/types/entities/attachment.rs b/src/types/entities/attachment.rs index f2e221d..223dae2 100644 --- a/src/types/entities/attachment.rs +++ b/src/types/entities/attachment.rs @@ -3,6 +3,8 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. use serde::{Deserialize, Serialize}; +#[cfg(feature = "sqlx")] +use sqlx_pg_uint::PgU64; use crate::types::utils::Snowflake; @@ -16,11 +18,20 @@ pub struct Attachment { /// Max 1024 characters pub description: Option, pub content_type: Option, + #[cfg(not(feature = "sqlx"))] pub size: u64, + #[cfg(feature = "sqlx")] + pub size: PgU64, pub url: String, pub proxy_url: String, + #[cfg(not(feature = "sqlx"))] pub height: Option, + #[cfg(feature = "sqlx")] + pub height: Option, + #[cfg(not(feature = "sqlx"))] pub width: Option, + #[cfg(feature = "sqlx")] + pub width: Option, pub ephemeral: Option, /// The duration of the audio file (only for voice messages) pub duration_secs: Option, @@ -42,7 +53,10 @@ pub struct PartialDiscordFileAttachment { /// Max 1024 characters pub description: Option, pub content_type: Option, - pub size: Option, + #[cfg(not(feature = "sqlx"))] + pub size: Option, + #[cfg(feature = "sqlx")] + pub size: Option, pub url: Option, pub proxy_url: Option, pub height: Option, diff --git a/src/types/entities/audit_log.rs b/src/types/entities/audit_log.rs index 7c821fc..d8ce347 100644 --- a/src/types/entities/audit_log.rs +++ b/src/types/entities/audit_log.rs @@ -7,6 +7,8 @@ use super::option_vec_arc_rwlock_ptr_eq; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; +#[cfg(feature = "sqlx")] +use sqlx_pg_uint::PgU64; use crate::types::utils::Snowflake; use crate::types::{ @@ -251,16 +253,28 @@ pub struct AuditEntryInfo { pub auto_moderation_rule_trigger_type: Option, pub channel_id: Option, // #[serde(option_string)] + #[cfg(not(feature = "sqlx"))] pub count: Option, + #[cfg(feature = "sqlx")] + pub count: Option, // #[serde(option_string)] + #[cfg(not(feature = "sqlx"))] pub delete_member_days: Option, + #[cfg(feature = "sqlx")] + pub delete_member_days: Option, /// The ID of the overwritten entity pub id: Option, pub integration_type: Option, // #[serde(option_string)] + #[cfg(not(feature = "sqlx"))] pub members_removed: Option, + #[cfg(feature = "sqlx")] + pub members_removed: Option, // #[serde(option_string)] + #[cfg(not(feature = "sqlx"))] pub message_id: Option, + #[cfg(feature = "sqlx")] + pub message_id: Option, pub role_name: Option, #[serde(rename = "type")] pub overwrite_type: Option, diff --git a/src/types/entities/channel.rs b/src/types/entities/channel.rs index 9e0199e..a2f7d7f 100644 --- a/src/types/entities/channel.rs +++ b/src/types/entities/channel.rs @@ -293,7 +293,10 @@ pub struct ThreadMember { pub id: Option, pub user_id: Option, pub join_timestamp: Option>, + #[cfg(not(feature = "sqlx"))] pub flags: Option, + #[cfg(feature = "sqlx")] + pub flags: Option, pub member: Option>, } diff --git a/src/types/entities/guild.rs b/src/types/entities/guild.rs index cca9b94..57b555f 100644 --- a/src/types/entities/guild.rs +++ b/src/types/entities/guild.rs @@ -273,7 +273,10 @@ pub struct GuildScheduledEvent { pub entity_id: Option, pub entity_metadata: Option, pub creator: Option>, + #[cfg(not(feature = "sqlx"))] pub user_count: Option, + #[cfg(feature = "sqlx")] + pub user_count: Option, pub image: Option, } diff --git a/src/types/entities/security_key.rs b/src/types/entities/security_key.rs index 7e0bb6b..3af45d1 100644 --- a/src/types/entities/security_key.rs +++ b/src/types/entities/security_key.rs @@ -13,7 +13,10 @@ pub struct SecurityKey { pub user_id: String, pub key_id: String, pub public_key: String, + #[cfg(not(feature = "sqlx"))] pub counter: u64, + #[cfg(feature = "sqlx")] + pub counter: sqlx_pg_uint::PgU64, pub name: String, } @@ -24,7 +27,10 @@ impl Default for SecurityKey { user_id: String::new(), key_id: String::new(), public_key: String::new(), + #[cfg(not(feature = "sqlx"))] counter: 0, + #[cfg(feature = "sqlx")] + counter: sqlx_pg_uint::PgU64::from(0), name: String::new(), } } diff --git a/src/types/entities/template.rs b/src/types/entities/template.rs index e82ec17..dca74b2 100644 --- a/src/types/entities/template.rs +++ b/src/types/entities/template.rs @@ -6,9 +6,9 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use crate::types::{ - Shared, entities::{Guild, User}, utils::Snowflake, + Shared, }; /// See @@ -18,7 +18,10 @@ pub struct GuildTemplate { pub code: String, pub name: String, pub description: Option, + #[cfg(not(feature = "sqlx"))] pub usage_count: Option, + #[cfg(feature = "sqlx")] + pub usage_count: Option, pub creator_id: Snowflake, #[cfg_attr(feature = "sqlx", sqlx(skip))] pub creator: Shared,