Compare commits

..

3 Commits

Author SHA1 Message Date
bitfl0wer 6916984225
Bump: wasm-bindgen* crate versions 2024-08-21 19:16:15 +02:00
bitfl0wer 859f3be213
Fix: Conditional compiling errors and warnings 2024-08-21 19:09:57 +02:00
bitfl0wer 4921487b33
Replace conditional compiling of uNN/PgUNN with conditional compiled type alias 2024-08-21 19:05:50 +02:00
19 changed files with 108 additions and 160 deletions

View File

@ -101,7 +101,7 @@ jobs:
run: | run: |
rustup target add wasm32-unknown-unknown rustup target add wasm32-unknown-unknown
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.92" --force cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.93" --force
GECKODRIVER=$(which geckodriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway" GECKODRIVER=$(which geckodriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway"
wasm-chrome: wasm-chrome:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -130,5 +130,5 @@ jobs:
run: | run: |
rustup target add wasm32-unknown-unknown rustup target add wasm32-unknown-unknown
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.92" --force cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.93" --force
CHROMEDRIVER=$(which chromedriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway" CHROMEDRIVER=$(which chromedriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt, voice_gateway"

37
Cargo.lock generated
View File

@ -17,6 +17,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]] [[package]]
name = "aead" name = "aead"
version = "0.5.2" version = "0.5.2"
@ -122,7 +128,7 @@ dependencies = [
"cc", "cc",
"cfg-if", "cfg-if",
"libc", "libc",
"miniz_oxide", "miniz_oxide 0.7.4",
"object", "object",
"rustc-demangle", "rustc-demangle",
] ]
@ -584,12 +590,12 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.31" version = "1.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" checksum = "9c0596c1eac1f9e04ed902702e9878208b336edc9d6fddc8a48387349bab3666"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide 0.8.0",
] ]
[[package]] [[package]]
@ -769,9 +775,9 @@ dependencies = [
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.5" version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205"
dependencies = [ dependencies = [
"atomic-waker", "atomic-waker",
"bytes", "bytes",
@ -992,7 +998,7 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"h2 0.4.5", "h2 0.4.6",
"http 1.1.0", "http 1.1.0",
"http-body 1.0.1", "http-body 1.0.1",
"httparse", "httparse",
@ -1157,9 +1163,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.157" version = "0.2.158"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
[[package]] [[package]]
name = "libm" name = "libm"
@ -1263,6 +1269,15 @@ dependencies = [
"adler", "adler",
] ]
[[package]]
name = "miniz_oxide"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
]
[[package]] [[package]]
name = "mio" name = "mio"
version = "1.0.2" version = "1.0.2"
@ -2763,9 +2778,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-properties" name = "unicode-properties"
version = "0.1.1" version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4259d9d4425d9f0661581b804cb85fe66a4c631cadd8f490d1c13a35d5d9291" checksum = "52ea75f83c0137a9b98608359a5f1af8144876eb67bcb1ce837368e906a9f524"
[[package]] [[package]]
name = "unicode_categories" name = "unicode_categories"

View File

@ -82,13 +82,13 @@ getrandom = { version = "0.2.15" }
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.15", features = ["js"] } getrandom = { version = "0.2.15", features = ["js"] }
ws_stream_wasm = "0.7.4" ws_stream_wasm = "0.7.4"
wasm-bindgen-futures = "0.4.42" wasm-bindgen-futures = "0.4.43"
wasmtimer = "0.2.0" wasmtimer = "0.2.0"
[dev-dependencies] [dev-dependencies]
lazy_static = "1.5.0" lazy_static = "1.5.0"
wasm-bindgen-test = "0.3.42" wasm-bindgen-test = "0.3.43"
wasm-bindgen = "0.2.92" wasm-bindgen = "0.2.93"
simple_logger = { version = "5.0.0", default-features = false } simple_logger = { version = "5.0.0", default-features = false }
[lints.rust] [lints.rust]

View File

@ -16,6 +16,7 @@ use crate::types::{
}; };
impl Message { impl Message {
#[allow(clippy::useless_conversion)]
/// Sends a message in the channel with the provided channel_id. /// Sends a message in the channel with the provided channel_id.
/// Returns the sent message. /// Returns the sent message.
/// ///

View File

@ -101,8 +101,7 @@ This crate uses Semantic Versioning 2.0.0 as its versioning scheme. You can read
clippy::extra_unused_lifetimes, clippy::extra_unused_lifetimes,
clippy::from_over_into, clippy::from_over_into,
clippy::needless_borrow, clippy::needless_borrow,
clippy::new_without_default, clippy::new_without_default
clippy::useless_conversion
)] )]
#![warn( #![warn(
clippy::todo, clippy::todo,
@ -111,7 +110,8 @@ This crate uses Semantic Versioning 2.0.0 as its versioning scheme. You can read
clippy::print_stdout, clippy::print_stdout,
clippy::print_stderr, clippy::print_stderr,
missing_debug_implementations, missing_debug_implementations,
missing_copy_implementations missing_copy_implementations,
clippy::useless_conversion
)] )]
#[cfg(all(feature = "rt", feature = "rt_multi_thread"))] #[cfg(all(feature = "rt", feature = "rt_multi_thread"))]
compile_error!("feature \"rt\" and feature \"rt_multi_thread\" cannot be enabled at the same time"); compile_error!("feature \"rt\" and feature \"rt_multi_thread\" cannot be enabled at the same time");
@ -139,6 +139,27 @@ pub mod types;
))] ))]
pub mod voice; pub mod voice;
#[cfg(not(feature = "sqlx"))]
pub type UInt128 = u128;
#[cfg(feature = "sqlx")]
pub type UInt128 = sqlx_pg_uint::PgU128;
#[cfg(not(feature = "sqlx"))]
pub type UInt64 = u64;
#[cfg(feature = "sqlx")]
pub type UInt64 = sqlx_pg_uint::PgU64;
#[cfg(not(feature = "sqlx"))]
pub type UInt32 = u32;
#[cfg(feature = "sqlx")]
pub type UInt32 = sqlx_pg_uint::PgU32;
#[cfg(not(feature = "sqlx"))]
pub type UInt16 = u16;
#[cfg(feature = "sqlx")]
pub type UInt16 = sqlx_pg_uint::PgU16;
#[cfg(not(feature = "sqlx"))]
pub type UInt8 = u8;
#[cfg(feature = "sqlx")]
pub type UInt8 = sqlx_pg_uint::PgU8;
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Clone, Default, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
/// A URLBundle bundles together the API-, Gateway- and CDN-URLs of a Spacebar instance. /// A URLBundle bundles together the API-, Gateway- and CDN-URLs of a Spacebar instance.
/// ///

View File

@ -3,10 +3,9 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(feature = "sqlx")]
use sqlx_pg_uint::PgU64;
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use crate::UInt64;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, PartialOrd)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, PartialOrd)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
@ -18,20 +17,11 @@ pub struct Attachment {
/// Max 1024 characters /// Max 1024 characters
pub description: Option<String>, pub description: Option<String>,
pub content_type: Option<String>, pub content_type: Option<String>,
#[cfg(not(feature = "sqlx"))] pub size: UInt64,
pub size: u64,
#[cfg(feature = "sqlx")]
pub size: PgU64,
pub url: String, pub url: String,
pub proxy_url: String, pub proxy_url: String,
#[cfg(not(feature = "sqlx"))] pub height: Option<UInt64>,
pub height: Option<u64>, pub width: Option<UInt64>,
#[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>, pub ephemeral: Option<bool>,
/// The duration of the audio file (only for voice messages) /// The duration of the audio file (only for voice messages)
pub duration_secs: Option<f32>, pub duration_secs: Option<f32>,
@ -48,18 +38,12 @@ pub struct Attachment {
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct PartialDiscordFileAttachment { pub struct PartialDiscordFileAttachment {
#[cfg(not(feature = "sqlx"))] pub id: Option<UInt64>,
pub id: Option<u64>,
#[cfg(feature = "sqlx")]
pub id: Option<PgU64>,
pub filename: String, pub filename: String,
/// Max 1024 characters /// Max 1024 characters
pub description: Option<String>, pub description: Option<String>,
pub content_type: Option<String>, pub content_type: Option<String>,
#[cfg(not(feature = "sqlx"))] pub size: Option<UInt64>,
pub size: Option<u64>,
#[cfg(feature = "sqlx")]
pub size: Option<PgU64>,
pub url: Option<String>, pub url: Option<String>,
pub proxy_url: Option<String>, pub proxy_url: Option<String>,
pub height: Option<i32>, pub height: Option<i32>,

View File

@ -7,13 +7,12 @@ use super::option_vec_arc_rwlock_ptr_eq;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr}; use serde_repr::{Deserialize_repr, Serialize_repr};
#[cfg(feature = "sqlx")]
use sqlx_pg_uint::PgU64;
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use crate::types::{ use crate::types::{
AutoModerationRuleTriggerType, IntegrationType, PermissionOverwriteType, Shared, AutoModerationRuleTriggerType, IntegrationType, PermissionOverwriteType, Shared,
}; };
use crate::UInt64;
#[derive(Serialize, Deserialize, Debug, Default, Clone)] #[derive(Serialize, Deserialize, Debug, Default, Clone)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
@ -254,28 +253,16 @@ pub struct AuditEntryInfo {
pub auto_moderation_rule_trigger_type: Option<AutoModerationRuleTriggerType>, pub auto_moderation_rule_trigger_type: Option<AutoModerationRuleTriggerType>,
pub channel_id: Option<Snowflake>, pub channel_id: Option<Snowflake>,
// #[serde(option_string)] // #[serde(option_string)]
#[cfg(not(feature = "sqlx"))] pub count: Option<UInt64>,
pub count: Option<u64>,
#[cfg(feature = "sqlx")]
pub count: Option<PgU64>,
// #[serde(option_string)] // #[serde(option_string)]
#[cfg(not(feature = "sqlx"))] pub delete_member_days: Option<UInt64>,
pub delete_member_days: Option<u64>,
#[cfg(feature = "sqlx")]
pub delete_member_days: Option<PgU64>,
/// The ID of the overwritten entity /// The ID of the overwritten entity
pub id: Option<Snowflake>, pub id: Option<Snowflake>,
pub integration_type: Option<IntegrationType>, pub integration_type: Option<IntegrationType>,
// #[serde(option_string)] // #[serde(option_string)]
#[cfg(not(feature = "sqlx"))] pub members_removed: Option<UInt64>,
pub members_removed: Option<u64>,
#[cfg(feature = "sqlx")]
pub members_removed: Option<PgU64>,
// #[serde(option_string)] // #[serde(option_string)]
#[cfg(not(feature = "sqlx"))] pub message_id: Option<UInt64>,
pub message_id: Option<u64>,
#[cfg(feature = "sqlx")]
pub message_id: Option<PgU64>,
pub role_name: Option<String>, pub role_name: Option<String>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub overwrite_type: Option<PermissionOverwriteType>, pub overwrite_type: Option<PermissionOverwriteType>,

View File

@ -5,6 +5,7 @@
#[cfg(feature = "client")] #[cfg(feature = "client")]
use crate::gateway::Updateable; use crate::gateway::Updateable;
use crate::types::Shared; use crate::types::Shared;
use crate::UInt8;
#[cfg(feature = "client")] #[cfg(feature = "client")]
use chorus_macros::Updateable; use chorus_macros::Updateable;
@ -82,14 +83,12 @@ pub struct AutoModerationRuleTriggerMetadataForKeywordPreset {
pub allow_list: Vec<String>, pub allow_list: Vec<String>,
} }
#[allow(missing_copy_implementations)]
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] #[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-metadata>
pub struct AutoModerationRuleTriggerMetadataForMentionSpam { pub struct AutoModerationRuleTriggerMetadataForMentionSpam {
/// Max 50 /// Max 50
#[cfg(not(feature = "sqlx"))] pub mention_total_limit: UInt8,
pub mention_total_limit: u8,
#[cfg(feature = "sqlx")]
pub mention_total_limit: sqlx_pg_uint::PgU8,
pub mention_raid_protection_enabled: bool, pub mention_raid_protection_enabled: bool,
} }

View File

@ -22,6 +22,7 @@ use crate::gateway::GatewayHandle;
#[cfg(feature = "client")] #[cfg(feature = "client")]
use crate::gateway::Updateable; use crate::gateway::Updateable;
use crate::UInt64;
#[cfg(feature = "client")] #[cfg(feature = "client")]
use chorus_macros::{observe_option_vec, Composite, Updateable}; use chorus_macros::{observe_option_vec, Composite, Updateable};
@ -296,10 +297,7 @@ pub struct ThreadMember {
pub id: Option<Snowflake>, pub id: Option<Snowflake>,
pub user_id: Option<Snowflake>, pub user_id: Option<Snowflake>,
pub join_timestamp: Option<DateTime<Utc>>, pub join_timestamp: Option<DateTime<Utc>>,
#[cfg(not(feature = "sqlx"))] pub flags: Option<UInt64>,
pub flags: Option<u64>,
#[cfg(feature = "sqlx")]
pub flags: Option<sqlx_pg_uint::PgU64>,
pub member: Option<Shared<GuildMember>>, pub member: Option<Shared<GuildMember>>,
} }

View File

@ -17,6 +17,7 @@ use crate::types::{
interfaces::WelcomeScreenObject, interfaces::WelcomeScreenObject,
utils::Snowflake, utils::Snowflake,
}; };
use crate::UInt64;
use super::{option_arc_rwlock_ptr_eq, vec_arc_rwlock_ptr_eq, PublicUser}; use super::{option_arc_rwlock_ptr_eq, vec_arc_rwlock_ptr_eq, PublicUser};
@ -273,10 +274,7 @@ pub struct GuildScheduledEvent {
pub entity_id: Option<Snowflake>, pub entity_id: Option<Snowflake>,
pub entity_metadata: Option<GuildScheduledEventEntityMetadata>, pub entity_metadata: Option<GuildScheduledEventEntityMetadata>,
pub creator: Option<Shared<User>>, pub creator: Option<Shared<User>>,
#[cfg(not(feature = "sqlx"))] pub user_count: Option<UInt64>,
pub user_count: Option<u64>,
#[cfg(feature = "sqlx")]
pub user_count: Option<sqlx_pg_uint::PgU64>,
pub image: Option<String>, pub image: Option<String>,
} }

View File

@ -10,6 +10,7 @@ use crate::types::{
utils::Snowflake, utils::Snowflake,
Shared, Shared,
}; };
use crate::{UInt16, UInt8};
#[derive(Default, Debug, Deserialize, Serialize, Clone)] #[derive(Default, Debug, Deserialize, Serialize, Clone)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
@ -23,14 +24,8 @@ pub struct Integration {
pub syncing: Option<bool>, pub syncing: Option<bool>,
pub role_id: Option<String>, pub role_id: Option<String>,
pub enabled_emoticons: Option<bool>, pub enabled_emoticons: Option<bool>,
#[cfg(not(feature = "sqlx"))] pub expire_behaviour: Option<UInt8>,
pub expire_behaviour: Option<u8>, pub expire_grace_period: Option<UInt16>,
#[cfg(feature = "sqlx")]
pub expire_behaviour: Option<sqlx_pg_uint::PgU8>,
#[cfg(not(feature = "sqlx"))]
pub expire_grace_period: Option<u16>,
#[cfg(feature = "sqlx")]
pub expire_grace_period: Option<sqlx_pg_uint::PgU16>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub user: Option<Shared<User>>, pub user: Option<Shared<User>>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]

View File

@ -10,6 +10,7 @@ use crate::types::{
Guild, InviteFlags, InviteTargetType, InviteType, Shared, Snowflake, VerificationLevel, Guild, InviteFlags, InviteTargetType, InviteType, Shared, Snowflake, VerificationLevel,
WelcomeScreenObject, WelcomeScreenObject,
}; };
use crate::{UInt32, UInt8};
use super::guild::GuildScheduledEvent; use super::guild::GuildScheduledEvent;
use super::{Application, Channel, GuildMember, NSFWLevel, User}; use super::{Application, Channel, GuildMember, NSFWLevel, User};
@ -39,14 +40,8 @@ pub struct Invite {
pub invite_type: Option<InviteType>, pub invite_type: Option<InviteType>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub inviter: Option<User>, pub inviter: Option<User>,
#[cfg(not(feature = "sqlx"))] pub max_age: Option<UInt32>,
pub max_age: Option<u32>, pub max_uses: Option<UInt8>,
#[cfg(feature = "sqlx")]
pub max_age: Option<sqlx_pg_uint::PgU32>,
#[cfg(not(feature = "sqlx"))]
pub max_uses: Option<u8>,
#[cfg(feature = "sqlx")]
pub max_uses: Option<sqlx_pg_uint::PgU8>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub stage_instance: Option<InviteStageInstance>, pub stage_instance: Option<InviteStageInstance>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
@ -56,10 +51,7 @@ pub struct Invite {
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub target_user: Option<User>, pub target_user: Option<User>,
pub temporary: Option<bool>, pub temporary: Option<bool>,
#[cfg(not(feature = "sqlx"))] pub uses: Option<UInt32>,
pub uses: Option<u32>,
#[cfg(feature = "sqlx")]
pub uses: Option<sqlx_pg_uint::PgU32>,
} }
/// The guild an invite is for. /// The guild an invite is for.

View File

@ -15,6 +15,7 @@ use crate::types::{
utils::Snowflake, utils::Snowflake,
Shared, Shared,
}; };
use crate::{UInt32, UInt8};
use super::option_arc_rwlock_ptr_eq; use super::option_arc_rwlock_ptr_eq;
@ -150,10 +151,7 @@ pub enum MessageReferenceType {
pub struct MessageInteraction { pub struct MessageInteraction {
pub id: Snowflake, pub id: Snowflake,
#[serde(rename = "type")] #[serde(rename = "type")]
#[cfg(not(feature = "sqlx"))] pub interaction_type: UInt8,
pub interaction_type: u8,
#[cfg(feature = "sqlx")]
pub interaction_type: sqlx_pg_uint::PgU8,
pub name: String, pub name: String,
pub user: User, pub user: User,
pub member: Option<Shared<GuildMember>>, pub member: Option<Shared<GuildMember>>,
@ -285,14 +283,8 @@ pub struct EmbedField {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Reaction { pub struct Reaction {
#[cfg(not(feature = "sqlx"))] pub count: UInt32,
pub count: u32, pub burst_count: UInt32,
#[cfg(feature = "sqlx")]
pub count: sqlx_pg_uint::PgU32,
#[cfg(not(feature = "sqlx"))]
pub burst_count: u32,
#[cfg(feature = "sqlx")]
pub burst_count: sqlx_pg_uint::PgU32,
#[serde(default)] #[serde(default)]
pub me: bool, pub me: bool,
#[serde(default)] #[serde(default)]

View File

@ -8,6 +8,7 @@ use serde_aux::prelude::deserialize_option_number_from_string;
use std::fmt::Debug; use std::fmt::Debug;
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use crate::{UInt16, UInt32};
#[cfg(feature = "client")] #[cfg(feature = "client")]
use chorus_macros::{Composite, Updateable}; use chorus_macros::{Composite, Updateable};
@ -32,10 +33,7 @@ pub struct RoleObject {
pub hoist: bool, pub hoist: bool,
pub icon: Option<String>, pub icon: Option<String>,
pub unicode_emoji: Option<String>, pub unicode_emoji: Option<String>,
#[cfg(not(feature = "sqlx"))] pub position: UInt16,
pub position: u16,
#[cfg(feature = "sqlx")]
pub position: sqlx_pg_uint::PgU16,
#[serde(default)] #[serde(default)]
pub permissions: PermissionFlags, pub permissions: PermissionFlags,
pub managed: bool, pub managed: bool,
@ -50,10 +48,7 @@ pub struct RoleObject {
pub struct RoleSubscriptionData { pub struct RoleSubscriptionData {
pub role_subscription_listing_id: Snowflake, pub role_subscription_listing_id: Snowflake,
pub tier_name: String, pub tier_name: String,
#[cfg(not(feature = "sqlx"))] pub total_months_subscribed: UInt32,
pub total_months_subscribed: u32,
#[cfg(feature = "sqlx")]
pub total_months_subscribed: sqlx_pg_uint::PgU32,
pub is_renewal: bool, pub is_renewal: bool,
} }

View File

@ -5,6 +5,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use crate::UInt64;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
@ -13,10 +14,7 @@ pub struct SecurityKey {
pub user_id: String, pub user_id: String,
pub key_id: String, pub key_id: String,
pub public_key: String, pub public_key: String,
#[cfg(not(feature = "sqlx"))] pub counter: UInt64,
pub counter: u64,
#[cfg(feature = "sqlx")]
pub counter: sqlx_pg_uint::PgU64,
pub name: String, pub name: String,
} }
@ -27,10 +25,8 @@ impl Default for SecurityKey {
user_id: String::new(), user_id: String::new(),
key_id: String::new(), key_id: String::new(),
public_key: String::new(), public_key: String::new(),
#[cfg(not(feature = "sqlx"))] #[allow(clippy::useless_conversion)]
counter: 0, counter: 0u64.into(),
#[cfg(feature = "sqlx")]
counter: sqlx_pg_uint::PgU64::from(0),
name: String::new(), name: String::new(),
} }
} }

View File

@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
use crate::types::entities::User; use crate::types::entities::User;
use crate::types::Shared; use crate::types::Shared;
use crate::types::Snowflake; use crate::types::Snowflake;
use crate::UInt8;
use super::arc_rwlock_ptr_eq; use super::arc_rwlock_ptr_eq;
@ -34,10 +35,7 @@ impl PartialEq for Team {
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TeamMember { pub struct TeamMember {
#[cfg(not(feature = "sqlx"))] pub membership_state: UInt8,
pub membership_state: u8,
#[cfg(feature = "sqlx")]
pub membership_state: sqlx_pg_uint::PgU8,
pub permissions: Vec<String>, pub permissions: Vec<String>,
pub team_id: Snowflake, pub team_id: Snowflake,
pub user: Shared<User>, pub user: Shared<User>,

View File

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

View File

@ -4,6 +4,7 @@
use crate::errors::ChorusError; use crate::errors::ChorusError;
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use crate::{UInt32, UInt8};
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_aux::prelude::deserialize_option_number_from_string; use serde_aux::prelude::deserialize_option_number_from_string;
@ -47,10 +48,7 @@ pub struct User {
pub bot: Option<bool>, pub bot: Option<bool>,
pub system: Option<bool>, pub system: Option<bool>,
pub mfa_enabled: Option<bool>, pub mfa_enabled: Option<bool>,
#[cfg(not(feature = "sqlx"))] pub accent_color: Option<UInt32>,
pub accent_color: Option<u32>,
#[cfg(feature = "sqlx")]
pub accent_color: Option<sqlx_pg_uint::PgU32>,
#[cfg_attr(feature = "sqlx", sqlx(default))] #[cfg_attr(feature = "sqlx", sqlx(default))]
pub locale: Option<String>, pub locale: Option<String>,
pub verified: Option<bool>, pub verified: Option<bool>,
@ -61,10 +59,7 @@ pub struct User {
#[serde(deserialize_with = "deserialize_option_number_from_string")] #[serde(deserialize_with = "deserialize_option_number_from_string")]
pub flags: Option<UserFlags>, pub flags: Option<UserFlags>,
pub premium_since: Option<DateTime<Utc>>, pub premium_since: Option<DateTime<Utc>>,
#[cfg(not(feature = "sqlx"))] pub premium_type: Option<UInt8>,
pub premium_type: Option<u8>,
#[cfg(feature = "sqlx")]
pub premium_type: Option<sqlx_pg_uint::PgU8>,
pub pronouns: Option<String>, pub pronouns: Option<String>,
pub public_flags: Option<UserFlags>, pub public_flags: Option<UserFlags>,
pub banner: Option<String>, pub banner: Option<String>,
@ -150,19 +145,13 @@ pub struct PublicUser {
pub username: Option<String>, pub username: Option<String>,
pub discriminator: Option<String>, pub discriminator: Option<String>,
pub avatar: Option<String>, pub avatar: Option<String>,
#[cfg(not(feature = "sqlx"))] pub accent_color: Option<UInt32>,
pub accent_color: Option<u32>,
#[cfg(feature = "sqlx")]
pub accent_color: Option<sqlx_pg_uint::PgU32>,
pub banner: Option<String>, pub banner: Option<String>,
pub theme_colors: Option<ThemeColors>, pub theme_colors: Option<ThemeColors>,
pub pronouns: Option<String>, pub pronouns: Option<String>,
pub bot: Option<bool>, pub bot: Option<bool>,
pub bio: Option<String>, pub bio: Option<String>,
#[cfg(not(feature = "sqlx"))] pub premium_type: Option<UInt8>,
pub premium_type: Option<u8>,
#[cfg(feature = "sqlx")]
pub premium_type: Option<sqlx_pg_uint::PgU8>,
pub premium_since: Option<DateTime<Utc>>, pub premium_since: Option<DateTime<Utc>>,
pub public_flags: Option<UserFlags>, pub public_flags: Option<UserFlags>,
} }

View File

@ -6,6 +6,7 @@ use chrono::{serde::ts_milliseconds_option, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::Shared; use crate::types::Shared;
use crate::{UInt16, UInt32, UInt8};
use serde_aux::field_attributes::deserialize_option_number_from_string; use serde_aux::field_attributes::deserialize_option_number_from_string;
#[derive( #[derive(
@ -42,16 +43,10 @@ pub enum UserTheme {
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
pub struct UserSettings { pub struct UserSettings {
#[cfg(not(feature = "sqlx"))] pub afk_timeout: Option<UInt16>,
pub afk_timeout: Option<u16>,
#[cfg(feature = "sqlx")]
pub afk_timeout: Option<sqlx_pg_uint::PgU16>,
pub allow_accessibility_detection: bool, pub allow_accessibility_detection: bool,
pub animate_emoji: bool, pub animate_emoji: bool,
#[cfg(not(feature = "sqlx"))] pub animate_stickers: UInt8,
pub animate_stickers: u8,
#[cfg(feature = "sqlx")]
pub animate_stickers: sqlx_pg_uint::PgU8,
pub contact_sync_enabled: bool, pub contact_sync_enabled: bool,
pub convert_emoticons: bool, pub convert_emoticons: bool,
pub custom_status: Option<CustomStatus>, pub custom_status: Option<CustomStatus>,
@ -60,10 +55,7 @@ pub struct UserSettings {
pub developer_mode: bool, pub developer_mode: bool,
pub disable_games_tab: bool, pub disable_games_tab: bool,
pub enable_tts_command: bool, pub enable_tts_command: bool,
#[cfg(not(feature = "sqlx"))] pub explicit_content_filter: UInt8,
pub explicit_content_filter: u8,
#[cfg(feature = "sqlx")]
pub explicit_content_filter: sqlx_pg_uint::PgU8,
pub friend_source_flags: FriendSourceFlags, pub friend_source_flags: FriendSourceFlags,
pub gateway_connected: Option<bool>, pub gateway_connected: Option<bool>,
pub gif_auto_play: bool, pub gif_auto_play: bool,
@ -88,7 +80,8 @@ pub struct UserSettings {
impl Default for UserSettings { impl Default for UserSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
afk_timeout: Some(3600.into()), #[allow(clippy::useless_conversion)]
afk_timeout: Some(3600u16.into()),
allow_accessibility_detection: true, allow_accessibility_detection: true,
animate_emoji: true, animate_emoji: true,
#[cfg(not(feature = "sqlx"))] #[cfg(not(feature = "sqlx"))]
@ -156,10 +149,7 @@ impl Default for FriendSourceFlags {
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))] #[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct GuildFolder { pub struct GuildFolder {
#[cfg(not(feature = "sqlx"))] pub color: Option<UInt32>,
pub color: Option<u32>,
#[cfg(feature = "sqlx")]
pub color: Option<sqlx_pg_uint::PgU32>,
pub guild_ids: Vec<String>, pub guild_ids: Vec<String>,
// FIXME: What is this thing? // FIXME: What is this thing?
// It's not a snowflake, and it's sometimes a string and sometimes an integer. // It's not a snowflake, and it's sometimes a string and sometimes an integer.