swap u64 for PgU64 in some files

This commit is contained in:
bitfl0wer 2024-08-18 22:38:07 +02:00
parent f66dff446b
commit ce67efe93c
No known key found for this signature in database
GPG Key ID: 8D90CA11485CD14D
6 changed files with 45 additions and 2 deletions

View File

@ -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<String>,
pub content_type: Option<String>,
#[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<u64>,
#[cfg(feature = "sqlx")]
pub height: Option<PgU64>,
#[cfg(not(feature = "sqlx"))]
pub width: Option<u64>,
#[cfg(feature = "sqlx")]
pub width: Option<PgU64>,
pub ephemeral: Option<bool>,
/// The duration of the audio file (only for voice messages)
pub duration_secs: Option<f32>,
@ -42,7 +53,10 @@ pub struct PartialDiscordFileAttachment {
/// Max 1024 characters
pub description: Option<String>,
pub content_type: Option<String>,
pub size: Option<i64>,
#[cfg(not(feature = "sqlx"))]
pub size: Option<u64>,
#[cfg(feature = "sqlx")]
pub size: Option<PgU64>,
pub url: Option<String>,
pub proxy_url: Option<String>,
pub height: Option<i32>,

View File

@ -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<AutoModerationRuleTriggerType>,
pub channel_id: Option<Snowflake>,
// #[serde(option_string)]
#[cfg(not(feature = "sqlx"))]
pub count: Option<u64>,
#[cfg(feature = "sqlx")]
pub count: Option<PgU64>,
// #[serde(option_string)]
#[cfg(not(feature = "sqlx"))]
pub delete_member_days: Option<u64>,
#[cfg(feature = "sqlx")]
pub delete_member_days: Option<PgU64>,
/// The ID of the overwritten entity
pub id: Option<Snowflake>,
pub integration_type: Option<IntegrationType>,
// #[serde(option_string)]
#[cfg(not(feature = "sqlx"))]
pub members_removed: Option<u64>,
#[cfg(feature = "sqlx")]
pub members_removed: Option<PgU64>,
// #[serde(option_string)]
#[cfg(not(feature = "sqlx"))]
pub message_id: Option<u64>,
#[cfg(feature = "sqlx")]
pub message_id: Option<PgU64>,
pub role_name: Option<String>,
#[serde(rename = "type")]
pub overwrite_type: Option<PermissionOverwriteType>,

View File

@ -293,7 +293,10 @@ pub struct ThreadMember {
pub id: Option<Snowflake>,
pub user_id: Option<Snowflake>,
pub join_timestamp: Option<DateTime<Utc>>,
#[cfg(not(feature = "sqlx"))]
pub flags: Option<u64>,
#[cfg(feature = "sqlx")]
pub flags: Option<sqlx_pg_uint::PgU64>,
pub member: Option<Shared<GuildMember>>,
}

View File

@ -273,7 +273,10 @@ pub struct GuildScheduledEvent {
pub entity_id: Option<Snowflake>,
pub entity_metadata: Option<GuildScheduledEventEntityMetadata>,
pub creator: Option<Shared<User>>,
#[cfg(not(feature = "sqlx"))]
pub user_count: Option<u64>,
#[cfg(feature = "sqlx")]
pub user_count: Option<sqlx_pg_uint::PgU64>,
pub image: Option<String>,
}

View File

@ -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(),
}
}

View File

@ -6,9 +6,9 @@ use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::types::{
Shared,
entities::{Guild, User},
utils::Snowflake,
Shared,
};
/// See <https://docs.spacebar.chat/routes/#cmp--schemas-template>
@ -18,7 +18,10 @@ pub struct GuildTemplate {
pub code: String,
pub name: String,
pub description: Option<String>,
#[cfg(not(feature = "sqlx"))]
pub usage_count: Option<u64>,
#[cfg(feature = "sqlx")]
pub usage_count: Option<sqlx_pg_uint::PgU64>,
pub creator_id: Snowflake,
#[cfg_attr(feature = "sqlx", sqlx(skip))]
pub creator: Shared<User>,