Initial support for PostgreSQL (#548)

* Change sqlx::Any to sqlx::Postgres

* Change sqlx::Any to sqlx::Postgres

* Remove JSONified overrides when sqlx feature is enabled, where it makes sense

* Add num-bigint dep

* Remove generic impl for From<T> for Snowflake
For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why.

* Remove num_bigint, adsd sqlx-pg-uint

* swap u64 for PgU64 in some files

* use v0.3.0 of sqlx-pg-uint

* Lots of sqlx-postgres type changes

* Lots of sqlx-postgres type changes

* gwah

* Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities

* impl sqlx::postgres::PgHasArrayType for Snowflake

* Try: derive Type for FriendSourceFlags, GuildFolder

* Try: Derive FromRow, Type for DefaultReaction

* Try: Derive Type for CustomStatus

* Try: Derive Type, FromRow for Tag

* Replace conditional compiling of uNN/PgUNN with conditional compiled type alias

* Fix: Conditional compiling errors and warnings

* Bump: wasm-bindgen* crate versions
This commit is contained in:
Flori 2024-08-21 23:43:42 +02:00 committed by GitHub
parent ec9541f38e
commit 86b022912f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 477 additions and 272 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"

343
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"
@ -77,7 +83,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -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",
] ]
@ -151,6 +157,20 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
[[package]]
name = "bigdecimal"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d712318a27c7150326677b321a5fa91b55f6d9034ffd67f20319e147d40cee"
dependencies = [
"autocfg",
"libm",
"num-bigint",
"num-integer",
"num-traits",
"serde",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -189,15 +209,18 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.6.0" version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.0" version = "1.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48"
dependencies = [
"shlex",
]
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -207,9 +230,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "cfg_aliases" name = "cfg_aliases"
version = "0.1.1" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]] [[package]]
name = "chorus" name = "chorus"
@ -244,6 +267,7 @@ dependencies = [
"serde_with", "serde_with",
"simple_logger", "simple_logger",
"sqlx", "sqlx",
"sqlx-pg-uint",
"thiserror", "thiserror",
"tokio", "tokio",
"tokio-tungstenite", "tokio-tungstenite",
@ -262,7 +286,7 @@ version = "0.4.1"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -328,15 +352,15 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.6" version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.12" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -433,7 +457,7 @@ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim", "strsim",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -444,7 +468,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
dependencies = [ dependencies = [
"darling_core", "darling_core",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -566,12 +590,12 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a"
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.0.30" 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 = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" checksum = "9c0596c1eac1f9e04ed902702e9878208b336edc9d6fddc8a48387349bab3666"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide 0.8.0",
] ]
[[package]] [[package]]
@ -667,7 +691,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -742,7 +766,7 @@ dependencies = [
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"http 0.2.12", "http 0.2.12",
"indexmap 2.2.6", "indexmap 2.4.0",
"slab", "slab",
"tokio", "tokio",
"tokio-util", "tokio-util",
@ -751,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",
@ -761,7 +785,7 @@ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"http 1.1.0", "http 1.1.0",
"indexmap 2.2.6", "indexmap 2.4.0",
"slab", "slab",
"tokio", "tokio",
"tokio-util", "tokio-util",
@ -908,9 +932,9 @@ dependencies = [
[[package]] [[package]]
name = "http-body" name = "http-body"
version = "1.0.0" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [ dependencies = [
"bytes", "bytes",
"http 1.1.0", "http 1.1.0",
@ -925,7 +949,7 @@ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.1.0", "http 1.1.0",
"http-body 1.0.0", "http-body 1.0.1",
"pin-project-lite", "pin-project-lite",
] ]
@ -974,9 +998,9 @@ 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.0", "http-body 1.0.1",
"httparse", "httparse",
"httpdate", "httpdate",
"itoa", "itoa",
@ -1001,14 +1025,14 @@ dependencies = [
[[package]] [[package]]
name = "hyper-util" name = "hyper-util"
version = "0.1.6" version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
"http 1.1.0", "http 1.1.0",
"http-body 1.0.0", "http-body 1.0.1",
"hyper 1.4.1", "hyper 1.4.1",
"pin-project-lite", "pin-project-lite",
"tokio", "tokio",
@ -1066,9 +1090,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.2.6" version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.14.5", "hashbrown 0.14.5",
@ -1107,9 +1131,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
[[package]] [[package]]
name = "js-sys" name = "js-sys"
version = "0.3.69" version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"
dependencies = [ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
@ -1139,9 +1163,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.155" 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 = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
[[package]] [[package]]
name = "libm" name = "libm"
@ -1220,6 +1244,16 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "minicov"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169"
dependencies = [
"cc",
"walkdir",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
@ -1236,10 +1270,19 @@ dependencies = [
] ]
[[package]] [[package]]
name = "mio" name = "miniz_oxide"
version = "1.0.1" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
]
[[package]]
name = "mio"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi",
"libc", "libc",
@ -1267,9 +1310,9 @@ dependencies = [
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.28.0" version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cfg-if", "cfg-if",
@ -1358,9 +1401,9 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.36.1" version = "0.36.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@ -1401,7 +1444,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall 0.5.2", "redox_syscall 0.5.3",
"smallvec", "smallvec",
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
@ -1517,9 +1560,9 @@ dependencies = [
[[package]] [[package]]
name = "poem" name = "poem"
version = "3.0.1" version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88b6912ed1e8833d7c22c9c986c517f4518d7d37e3c04566d917c789aaea591" checksum = "f1ba1c27f8f89e1bccdda0c680f72790545a11a8d8555819472f5839d7a8ca9d"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-util",
@ -1551,14 +1594,14 @@ dependencies = [
[[package]] [[package]]
name = "poem-derive" name = "poem-derive"
version = "3.0.0" version = "3.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2b961d58a6c53380c20236394381d9292fda03577f902b158f1638932964dcf" checksum = "a62fea1692d80a000126f9b28d865012a160b80000abb53ccf152b428222c155"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -1580,9 +1623,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
dependencies = [
"zerocopy",
]
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
@ -1661,18 +1707,18 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
] ]
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.5" version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -1849,9 +1895,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.7.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0"
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
@ -1878,6 +1924,15 @@ dependencies = [
"cipher", "cipher",
] ]
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.1" version = "1.0.1"
@ -1914,9 +1969,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.204" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
@ -1934,22 +1989,23 @@ dependencies = [
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.204" version = "1.0.208"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.120" version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr",
"ryu", "ryu",
"serde", "serde",
] ]
@ -1962,7 +2018,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -1987,7 +2043,7 @@ dependencies = [
"chrono", "chrono",
"hex", "hex",
"indexmap 1.9.3", "indexmap 1.9.3",
"indexmap 2.2.6", "indexmap 2.4.0",
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
@ -2004,7 +2060,7 @@ dependencies = [
"darling", "darling",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2029,6 +2085,12 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]] [[package]]
name = "signature" name = "signature"
version = "2.2.0" version = "2.2.0"
@ -2144,6 +2206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a999083c1af5b5d6c071d34a708a19ba3e02106ad82ef7bbd69f5e48266b613b" checksum = "a999083c1af5b5d6c071d34a708a19ba3e02106ad82ef7bbd69f5e48266b613b"
dependencies = [ dependencies = [
"atoi", "atoi",
"bigdecimal",
"byteorder", "byteorder",
"bytes", "bytes",
"chrono", "chrono",
@ -2159,7 +2222,7 @@ dependencies = [
"hashbrown 0.14.5", "hashbrown 0.14.5",
"hashlink", "hashlink",
"hex", "hex",
"indexmap 2.2.6", "indexmap 2.4.0",
"ipnetwork", "ipnetwork",
"log", "log",
"memchr", "memchr",
@ -2191,7 +2254,7 @@ dependencies = [
"quote", "quote",
"sqlx-core", "sqlx-core",
"sqlx-macros-core", "sqlx-macros-core",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2214,7 +2277,7 @@ dependencies = [
"sqlx-mysql", "sqlx-mysql",
"sqlx-postgres", "sqlx-postgres",
"sqlx-sqlite", "sqlx-sqlite",
"syn 2.0.70", "syn 2.0.75",
"tempfile", "tempfile",
"tokio", "tokio",
"url", "url",
@ -2228,6 +2291,7 @@ checksum = "5afe4c38a9b417b6a9a5eeffe7235d0a106716495536e7727d1c7f4b1ff3eba6"
dependencies = [ dependencies = [
"atoi", "atoi",
"base64 0.22.1", "base64 0.22.1",
"bigdecimal",
"bitflags 2.6.0", "bitflags 2.6.0",
"byteorder", "byteorder",
"bytes", "bytes",
@ -2263,6 +2327,27 @@ dependencies = [
"whoami", "whoami",
] ]
[[package]]
name = "sqlx-pg-uint"
version = "0.3.0"
source = "git+https://github.com/bitfl0wer/sqlx-pg-uint#a132f4ad12f6cd1f68cc07e01edd644b4735e346"
dependencies = [
"bigdecimal",
"serde",
"sqlx",
"sqlx-pg-uint-macros",
"thiserror",
]
[[package]]
name = "sqlx-pg-uint-macros"
version = "0.3.0"
source = "git+https://github.com/bitfl0wer/sqlx-pg-uint#a132f4ad12f6cd1f68cc07e01edd644b4735e346"
dependencies = [
"quote",
"syn 2.0.75",
]
[[package]] [[package]]
name = "sqlx-postgres" name = "sqlx-postgres"
version = "0.8.0" version = "0.8.0"
@ -2271,6 +2356,7 @@ checksum = "b1dbb157e65f10dbe01f729339c06d239120221c9ad9fa0ba8408c4cc18ecf21"
dependencies = [ dependencies = [
"atoi", "atoi",
"base64 0.22.1", "base64 0.22.1",
"bigdecimal",
"bitflags 2.6.0", "bitflags 2.6.0",
"byteorder", "byteorder",
"chrono", "chrono",
@ -2290,6 +2376,7 @@ dependencies = [
"log", "log",
"md-5", "md-5",
"memchr", "memchr",
"num-bigint",
"once_cell", "once_cell",
"rand", "rand",
"serde", "serde",
@ -2363,9 +2450,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.70" version = "2.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2410,14 +2497,15 @@ dependencies = [
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.10.1" version = "3.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"fastrand", "fastrand",
"once_cell",
"rustix", "rustix",
"windows-sys 0.52.0", "windows-sys 0.59.0",
] ]
[[package]] [[package]]
@ -2437,7 +2525,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2488,9 +2576,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.39.2" version = "1.39.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -2510,7 +2598,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2564,9 +2652,9 @@ dependencies = [
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.6" version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
@ -2574,16 +2662,16 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [ dependencies = [
"indexmap 2.2.6", "indexmap 2.4.0",
"toml_datetime", "toml_datetime",
"winnow", "winnow",
] ]
[[package]] [[package]]
name = "tower-service" name = "tower-service"
version = "0.3.2" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
[[package]] [[package]]
name = "tracing" name = "tracing"
@ -2605,7 +2693,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2690,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"
@ -2747,9 +2835,19 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]] [[package]]
name = "want" name = "want"
@ -2774,34 +2872,35 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
[[package]] [[package]]
name = "wasm-bindgen-backend" name = "wasm-bindgen-backend"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"
dependencies = [ dependencies = [
"bumpalo", "bumpalo",
"log", "log",
"once_cell", "once_cell",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
[[package]] [[package]]
name = "wasm-bindgen-futures" name = "wasm-bindgen-futures"
version = "0.4.42" version = "0.4.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys", "js-sys",
@ -2811,9 +2910,9 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"
dependencies = [ dependencies = [
"quote", "quote",
"wasm-bindgen-macro-support", "wasm-bindgen-macro-support",
@ -2821,31 +2920,32 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-macro-support" name = "wasm-bindgen-macro-support"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
"wasm-bindgen-backend", "wasm-bindgen-backend",
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
[[package]] [[package]]
name = "wasm-bindgen-shared" name = "wasm-bindgen-shared"
version = "0.2.92" version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]] [[package]]
name = "wasm-bindgen-test" name = "wasm-bindgen-test"
version = "0.3.42" version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9"
dependencies = [ dependencies = [
"console_error_panic_hook", "console_error_panic_hook",
"js-sys", "js-sys",
"minicov",
"scoped-tls", "scoped-tls",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
@ -2854,13 +2954,13 @@ dependencies = [
[[package]] [[package]]
name = "wasm-bindgen-test-macro" name = "wasm-bindgen-test-macro"
version = "0.3.42" version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]
@ -2879,9 +2979,9 @@ dependencies = [
[[package]] [[package]]
name = "web-sys" name = "web-sys"
version = "0.3.69" version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
@ -2934,6 +3034,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"
@ -2967,6 +3076,15 @@ dependencies = [
"windows-targets 0.52.6", "windows-targets 0.52.6",
] ]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]] [[package]]
name = "windows-targets" name = "windows-targets"
version = "0.48.5" version = "0.48.5"
@ -3132,6 +3250,7 @@ version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [ dependencies = [
"byteorder",
"zerocopy-derive", "zerocopy-derive",
] ]
@ -3143,7 +3262,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.70", "syn 2.0.75",
] ]
[[package]] [[package]]

View File

@ -13,17 +13,18 @@ rust-version = "1.70.0"
[features] [features]
default = ["client", "rt-multi-thread"] default = ["client", "rt-multi-thread"]
backend = ["poem", "sqlx"] backend = ["poem", "sqlx", "sqlx-pg-uint"]
rt-multi-thread = ["tokio/rt-multi-thread"] rt-multi-thread = ["tokio/rt-multi-thread"]
rt = ["tokio/rt"] rt = ["tokio/rt"]
client = ["flate2"] client = ["flate2"]
voice = ["voice_udp", "voice_gateway"] voice = ["voice_udp", "voice_gateway"]
voice_udp = ["dep:discortp", "dep:crypto_secretbox"] voice_udp = ["dep:discortp", "dep:crypto_secretbox"]
voice_gateway = [] voice_gateway = []
sqlx-pg-uint = ["dep:sqlx-pg-uint", "sqlx-pg-uint/serde"]
[dependencies] [dependencies]
tokio = { version = "1.38.1", features = ["macros", "sync"] } tokio = { version = "1.38.1", features = ["macros", "sync"] }
serde = { version = "1.0.204", features = ["derive", "rc"] } serde = { version = "1.0.208", features = ["derive", "rc"] }
serde_json = { version = "1.0.120", features = ["raw_value"] } serde_json = { version = "1.0.120", features = ["raw_value"] }
serde-aux = "4.5.0" serde-aux = "4.5.0"
serde_with = "3.9.0" serde_with = "3.9.0"
@ -49,13 +50,12 @@ log = "0.4.22"
async-trait = "0.1.81" async-trait = "0.1.81"
chorus-macros = { path = "./chorus-macros", version = "0" } # Note: version here is used when releasing. This will use the latest release. Make sure to republish the crate when code in macros is changed! chorus-macros = { path = "./chorus-macros", version = "0" } # Note: version here is used when releasing. This will use the latest release. Make sure to republish the crate when code in macros is changed!
sqlx = { version = "0.8.0", features = [ sqlx = { version = "0.8.0", features = [
"mysql",
"sqlite",
"json", "json",
"chrono", "chrono",
"ipnetwork", "ipnetwork",
"runtime-tokio-rustls", "runtime-tokio-rustls",
"any", "postgres",
"bigdecimal",
], optional = true } ], optional = true }
discortp = { version = "0.5.0", optional = true, features = [ discortp = { version = "0.5.0", optional = true, features = [
"rtp", "rtp",
@ -67,6 +67,9 @@ rand = "0.8.5"
flate2 = { version = "1.0.30", optional = true } flate2 = { version = "1.0.30", optional = true }
webpki-roots = "0.26.3" webpki-roots = "0.26.3"
pubserve = { version = "1.1.0", features = ["async", "send"] } pubserve = { version = "1.1.0", features = ["async", "send"] }
sqlx-pg-uint = { git = "https://github.com/bitfl0wer/sqlx-pg-uint", features = [
"serde",
], optional = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
rustls = "0.21.12" rustls = "0.21.12"
@ -79,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

@ -164,23 +164,23 @@ pub fn sqlx_bitflag_derive(input: TokenStream) -> TokenStream {
quote!{ quote!{
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl sqlx::Type<sqlx::Any> for #name { impl sqlx::Type<sqlx::Postgres> for #name {
fn type_info() -> sqlx::any::AnyTypeInfo { fn type_info() -> sqlx::postgres::PgTypeInfo {
<Vec<u8> as sqlx::Type<sqlx::Any>>::type_info() <Vec<u8> as sqlx::Type<sqlx::Postgres>>::type_info()
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'q> sqlx::Encode<'q, sqlx::Any> for #name { impl<'q> sqlx::Encode<'q, sqlx::Postgres> for #name {
fn encode_by_ref(&self, buf: &mut <sqlx::Any as sqlx::Database>::ArgumentBuffer<'q>) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { fn encode_by_ref(&self, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
<Vec<u8> as sqlx::Encode<sqlx::Any>>::encode_by_ref(&self.bits().to_be_bytes().into(), buf) <Vec<u8> as sqlx::Encode<sqlx::Postgres>>::encode_by_ref(&self.bits().to_be_bytes().into(), buf)
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'q> sqlx::Decode<'q, sqlx::Any> for #name { impl<'q> sqlx::Decode<'q, sqlx::Postgres> for #name {
fn decode(value: <sqlx::Any as sqlx::Database>::ValueRef<'q>) -> Result<Self, sqlx::error::BoxDynError> { fn decode(value: <sqlx::Postgres as sqlx::Database>::ValueRef<'q>) -> Result<Self, sqlx::error::BoxDynError> {
let vec = <Vec<u8> as sqlx::Decode<sqlx::Any>>::decode(value)?; let vec = <Vec<u8> as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
Ok(Self::from_bits(vec_u8_to_u64(vec)).unwrap()) Ok(Self::from_bits(vec_u8_to_u64(vec)).unwrap())
} }
} }

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.
/// ///
@ -40,7 +41,7 @@ impl Message {
chorus_request.deserialize_response::<Message>(user).await chorus_request.deserialize_response::<Message>(user).await
} else { } else {
for (index, attachment) in message.attachments.iter_mut().enumerate() { for (index, attachment) in message.attachments.iter_mut().enumerate() {
attachment.get_mut(index).unwrap().id = Some(index as i16); attachment.get_mut(index).unwrap().id = Some((index as u64).into());
} }
let mut form = reqwest::multipart::Form::new(); let mut form = reqwest::multipart::Form::new();
let payload_json = to_string(&message).unwrap(); let payload_json = to_string(&message).unwrap();

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

@ -162,11 +162,11 @@ impl Display for GuildFeaturesList {
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'r> sqlx::Decode<'r, sqlx::Any> for GuildFeaturesList { impl<'r> sqlx::Decode<'r, sqlx::Postgres> for GuildFeaturesList {
fn decode( fn decode(
value: <sqlx::Any as sqlx::Database>::ValueRef<'r>, value: <sqlx::Postgres as sqlx::Database>::ValueRef<'r>,
) -> Result<Self, sqlx::error::BoxDynError> { ) -> Result<Self, sqlx::error::BoxDynError> {
let v = <String as sqlx::Decode<sqlx::Any>>::decode(value)?; let v = <String as sqlx::Decode<sqlx::Postgres>>::decode(value)?;
Ok(Self( Ok(Self(
v.split(',') v.split(',')
.filter(|f| !f.is_empty()) .filter(|f| !f.is_empty())
@ -177,10 +177,10 @@ impl<'r> sqlx::Decode<'r, sqlx::Any> for GuildFeaturesList {
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'q> sqlx::Encode<'q, sqlx::Any> for GuildFeaturesList { impl<'q> sqlx::Encode<'q, sqlx::Postgres> for GuildFeaturesList {
fn encode_by_ref( fn encode_by_ref(
&self, &self,
buf: &mut <sqlx::Any as sqlx::Database>::ArgumentBuffer<'q>, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync>> {
if self.is_empty() { if self.is_empty() {
return Ok(sqlx::encode::IsNull::Yes); return Ok(sqlx::encode::IsNull::Yes);
@ -191,18 +191,18 @@ impl<'q> sqlx::Encode<'q, sqlx::Any> for GuildFeaturesList {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(","); .join(",");
<String as sqlx::Encode<sqlx::Any>>::encode_by_ref(&features, buf) <String as sqlx::Encode<sqlx::Postgres>>::encode_by_ref(&features, buf)
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl sqlx::Type<sqlx::Any> for GuildFeaturesList { impl sqlx::Type<sqlx::Postgres> for GuildFeaturesList {
fn type_info() -> sqlx::any::AnyTypeInfo { fn type_info() -> <sqlx::Postgres as sqlx::Database>::TypeInfo {
<String as sqlx::Type<sqlx::Any>>::type_info() <String as sqlx::Type<sqlx::Postgres>>::type_info()
} }
fn compatible(ty: &sqlx::any::AnyTypeInfo) -> bool { fn compatible(ty: &<sqlx::Postgres as sqlx::Database>::TypeInfo) -> bool {
<String as sqlx::Type<sqlx::Any>>::compatible(ty) <String as sqlx::Type<sqlx::Postgres>>::compatible(ty)
} }
} }

View File

@ -224,7 +224,8 @@ pub struct ApplicationCommandOptionChoice {
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)] #[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(i32)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// # Reference /// # Reference
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types> /// See <https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types>
pub enum ApplicationCommandOptionType { pub enum ApplicationCommandOptionType {
@ -294,7 +295,8 @@ pub struct ApplicationCommandPermission {
Ord, Ord,
)] )]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type> /// See <https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permission-type>
pub enum ApplicationCommandPermissionType { pub enum ApplicationCommandPermissionType {
#[default] #[default]

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, Serialize, Deserialize, PartialOrd)] #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, PartialOrd)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))] #[cfg_attr(feature = "sqlx", derive(sqlx::FromRow))]
@ -16,11 +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>,
pub size: u64, pub size: UInt64,
pub url: String, pub url: String,
pub proxy_url: String, pub proxy_url: String,
pub height: Option<u64>, pub height: Option<UInt64>,
pub width: Option<u64>, pub width: Option<UInt64>,
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>,
@ -37,12 +38,12 @@ pub struct Attachment {
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct PartialDiscordFileAttachment { pub struct PartialDiscordFileAttachment {
pub id: Option<i16>, pub id: Option<UInt64>,
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>,
pub size: Option<i64>, pub size: Option<UInt64>,
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

@ -12,6 +12,7 @@ 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))]
@ -108,7 +109,8 @@ pub struct AuditLogChange {
PartialOrd, PartialOrd,
Ord, Ord,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference: /// # Reference:
/// See <https://docs.discord.sex/resources/audit-log#audit-log-events> /// See <https://docs.discord.sex/resources/audit-log#audit-log-events>
@ -251,16 +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)]
pub count: Option<u64>, pub count: Option<UInt64>,
// #[serde(option_string)] // #[serde(option_string)]
pub delete_member_days: Option<u64>, pub delete_member_days: Option<UInt64>,
/// 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)]
pub members_removed: Option<u64>, pub members_removed: Option<UInt64>,
// #[serde(option_string)] // #[serde(option_string)]
pub message_id: Option<u64>, pub message_id: Option<UInt64>,
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;
@ -32,7 +33,8 @@ pub struct AutoModerationRule {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy)]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types>
pub enum AutoModerationRuleEventType { pub enum AutoModerationRuleEventType {
@ -43,7 +45,8 @@ pub enum AutoModerationRuleEventType {
#[derive( #[derive(
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types>
pub enum AutoModerationRuleTriggerType { pub enum AutoModerationRuleTriggerType {
@ -80,18 +83,20 @@ pub struct AutoModerationRuleTriggerMetadataForKeywordPreset {
pub allow_list: Vec<String>, pub allow_list: Vec<String>,
} }
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy)] #[allow(missing_copy_implementations)]
#[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
pub mention_total_limit: u8, pub mention_total_limit: UInt8,
pub mention_raid_protection_enabled: bool, pub mention_raid_protection_enabled: bool,
} }
#[derive( #[derive(
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types>
pub enum AutoModerationRuleKeywordPresetType { pub enum AutoModerationRuleKeywordPresetType {
@ -110,9 +115,20 @@ pub struct AutoModerationAction {
} }
#[derive( #[derive(
Serialize_repr, Deserialize_repr, Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Copy, Hash Serialize_repr,
Deserialize_repr,
Debug,
Clone,
Default,
PartialEq,
Eq,
PartialOrd,
Ord,
Copy,
Hash,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types> /// See <https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types>
pub enum AutoModerationActionType { pub enum AutoModerationActionType {

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};
@ -41,13 +42,7 @@ use super::{option_arc_rwlock_ptr_eq, option_vec_arc_rwlock_ptr_eq};
/// See <https://discord-userdoccers.vercel.app/resources/channel#channels-resource> /// See <https://discord-userdoccers.vercel.app/resources/channel#channels-resource>
pub struct Channel { pub struct Channel {
pub application_id: Option<Snowflake>, pub application_id: Option<Snowflake>,
#[cfg(feature = "sqlx")]
pub applied_tags: Option<sqlx::types::Json<Vec<String>>>,
#[cfg(not(feature = "sqlx"))]
pub applied_tags: Option<Vec<String>>, pub applied_tags: Option<Vec<String>>,
#[cfg(feature = "sqlx")]
pub available_tags: Option<sqlx::types::Json<Vec<Tag>>>,
#[cfg(not(feature = "sqlx"))]
pub available_tags: Option<Vec<Tag>>, pub available_tags: Option<Vec<Tag>>,
pub bitrate: Option<i32>, pub bitrate: Option<i32>,
#[serde(rename = "type")] #[serde(rename = "type")]
@ -55,9 +50,7 @@ pub struct Channel {
pub created_at: Option<chrono::DateTime<Utc>>, pub created_at: Option<chrono::DateTime<Utc>>,
pub default_auto_archive_duration: Option<i32>, pub default_auto_archive_duration: Option<i32>,
pub default_forum_layout: Option<i32>, pub default_forum_layout: Option<i32>,
#[cfg(feature = "sqlx")] // DefaultReaction could be stored in a separate table. However, there are a lot of default emojis. How would we handle that?
pub default_reaction_emoji: Option<sqlx::types::Json<DefaultReaction>>,
#[cfg(not(feature = "sqlx"))]
pub default_reaction_emoji: Option<DefaultReaction>, pub default_reaction_emoji: Option<DefaultReaction>,
pub default_sort_order: Option<i32>, pub default_sort_order: Option<i32>,
pub default_thread_rate_limit_per_user: Option<i32>, pub default_thread_rate_limit_per_user: Option<i32>,
@ -179,6 +172,8 @@ fn compare_permission_overwrites(
/// ///
/// # Reference /// # Reference
/// See <https://discord-userdoccers.vercel.app/resources/channel#forum-tag-object> /// See <https://discord-userdoccers.vercel.app/resources/channel#forum-tag-object>
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct Tag { pub struct Tag {
pub id: Snowflake, pub id: Snowflake,
/// The name of the tag (max 20 characters) /// The name of the tag (max 20 characters)
@ -202,7 +197,8 @@ pub struct PermissionOverwrite {
} }
#[derive(Debug, Serialize_repr, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] #[derive(Debug, Serialize_repr, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// # Reference /// # Reference
/// ///
/// See <https://docs.discord.sex/resources/channel#permission-overwrite-type> /// See <https://docs.discord.sex/resources/channel#permission-overwrite-type>
@ -301,7 +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>>,
pub flags: Option<u64>, pub flags: Option<UInt64>,
pub member: Option<Shared<GuildMember>>, pub member: Option<Shared<GuildMember>>,
} }
@ -321,6 +317,8 @@ impl PartialEq for ThreadMember {
/// ///
/// # Reference /// # Reference
/// See <https://discord-userdoccers.vercel.app/resources/channel#default-reaction-object> /// See <https://discord-userdoccers.vercel.app/resources/channel#default-reaction-object>
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct DefaultReaction { pub struct DefaultReaction {
#[serde(default)] #[serde(default)]
pub emoji_id: Option<Snowflake>, pub emoji_id: Option<Snowflake>,
@ -342,7 +340,7 @@ pub struct DefaultReaction {
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[repr(u32)] #[repr(i32)]
/// # Reference /// # Reference
/// See <https://discord-userdoccers.vercel.app/resources/channel#channel-type> /// See <https://discord-userdoccers.vercel.app/resources/channel#channel-type>
pub enum ChannelType { pub enum ChannelType {

View File

@ -32,9 +32,6 @@ use super::option_arc_rwlock_ptr_eq;
pub struct Emoji { pub struct Emoji {
pub id: Snowflake, pub id: Snowflake,
pub name: Option<String>, pub name: Option<String>,
#[cfg(feature = "sqlx")]
pub roles: Option<sqlx::types::Json<Vec<Snowflake>>>,
#[cfg(not(feature = "sqlx"))]
pub roles: Option<Vec<Snowflake>>, pub roles: Option<Vec<Snowflake>>,
#[cfg_attr(feature = "sqlx", sqlx(skip))] #[cfg_attr(feature = "sqlx", sqlx(skip))]
pub user: Option<Shared<User>>, pub user: Option<Shared<User>>,

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,7 +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>>,
pub user_count: Option<u64>, pub user_count: Option<UInt64>,
pub image: Option<String>, pub image: Option<String>,
} }
@ -300,7 +301,8 @@ impl PartialEq for GuildScheduledEvent {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[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> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level>
pub enum GuildScheduledEventPrivacyLevel { pub enum GuildScheduledEventPrivacyLevel {
#[default] #[default]
@ -308,7 +310,8 @@ pub enum GuildScheduledEventPrivacyLevel {
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)] #[derive(Serialize_repr, Deserialize_repr, Debug, Default, Clone, PartialEq, Copy)]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status>
pub enum GuildScheduledEventStatus { pub enum GuildScheduledEventStatus {
#[default] #[default]
@ -331,7 +334,8 @@ pub enum GuildScheduledEventStatus {
Copy, Copy,
Hash, Hash,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[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> /// See <https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types>
pub enum GuildScheduledEventEntityType { pub enum GuildScheduledEventEntityType {
#[default] #[default]
@ -369,7 +373,8 @@ pub struct VoiceRegion {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#message-notification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#message-notification-level>
pub enum MessageNotificationLevel { pub enum MessageNotificationLevel {
@ -392,7 +397,8 @@ pub enum MessageNotificationLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#explicit-content-filter-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#explicit-content-filter-level>
pub enum ExplicitContentFilterLevel { pub enum ExplicitContentFilterLevel {
@ -416,7 +422,8 @@ pub enum ExplicitContentFilterLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum VerificationLevel { pub enum VerificationLevel {
@ -442,7 +449,8 @@ pub enum VerificationLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum MFALevel { pub enum MFALevel {
@ -465,7 +473,8 @@ pub enum MFALevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum NSFWLevel { pub enum NSFWLevel {
@ -490,7 +499,8 @@ pub enum NSFWLevel {
Ord, Ord,
)] )]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level> /// See <https://discord-userdoccers.vercel.app/resources/guild#verification-level>
pub enum PremiumTier { pub enum PremiumTier {

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,8 +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>,
pub expire_behaviour: Option<u8>, pub expire_behaviour: Option<UInt8>,
pub expire_grace_period: Option<u16>, pub expire_grace_period: Option<UInt16>,
#[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

@ -5,8 +5,12 @@
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::{Snowflake, WelcomeScreenObject, Shared, InviteFlags, InviteType, InviteTargetType, Guild, VerificationLevel};
use crate::types::types::guild_configuration::GuildFeaturesList; use crate::types::types::guild_configuration::GuildFeaturesList;
use crate::types::{
Guild, InviteFlags, InviteTargetType, InviteType, Shared, Snowflake, VerificationLevel,
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};
@ -36,8 +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>,
pub max_age: Option<u32>, pub max_age: Option<UInt32>,
pub max_uses: Option<u8>, pub max_uses: Option<UInt8>,
#[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))]
@ -47,7 +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>,
pub uses: Option<u32>, pub uses: Option<UInt32>,
} }
/// 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,7 +151,7 @@ pub enum MessageReferenceType {
pub struct MessageInteraction { pub struct MessageInteraction {
pub id: Snowflake, pub id: Snowflake,
#[serde(rename = "type")] #[serde(rename = "type")]
pub interaction_type: u8, pub interaction_type: UInt8,
pub name: String, pub name: String,
pub user: User, pub user: User,
pub member: Option<Shared<GuildMember>>, pub member: Option<Shared<GuildMember>>,
@ -282,8 +283,8 @@ pub struct EmbedField {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Reaction { pub struct Reaction {
pub count: u32, pub count: UInt32,
pub burst_count: u32, pub burst_count: UInt32,
#[serde(default)] #[serde(default)]
pub me: bool, pub me: bool,
#[serde(default)] #[serde(default)]
@ -296,6 +297,8 @@ pub struct Reaction {
} }
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Ord)] #[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, Eq, PartialOrd, Ord)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum Component { pub enum Component {
ActionRow = 1, ActionRow = 1,
Button = 2, Button = 2,
@ -320,7 +323,8 @@ pub struct MessageActivity {
Debug, Default, PartialEq, Clone, Copy, Serialize_repr, Deserialize_repr, Eq, PartialOrd, Ord, Debug, Default, PartialEq, Clone, Copy, Serialize_repr, Deserialize_repr, Eq, PartialOrd, Ord,
)] )]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference /// # Reference
/// See <https://docs.discord.sex/resources/message#message-type> /// See <https://docs.discord.sex/resources/message#message-type>
@ -464,7 +468,8 @@ pub struct PartialEmoji {
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, Eq, Hash)] #[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, PartialOrd, Ord, Eq, Hash)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum ReactionType { pub enum ReactionType {
Normal = 0, Normal = 0,
Burst = 1, // The dreaded super reactions Burst = 1, // The dreaded super reactions

View File

@ -45,7 +45,8 @@ impl PartialEq for Relationship {
Copy, Copy,
Hash, Hash,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
/// See <https://discord-userdoccers.vercel.app/resources/user#relationship-type> /// See <https://discord-userdoccers.vercel.app/resources/user#relationship-type>
pub enum RelationshipType { pub enum RelationshipType {
Suggestion = 6, Suggestion = 6,

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,7 +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>,
pub position: u16, pub position: UInt16,
#[serde(default)] #[serde(default)]
pub permissions: PermissionFlags, pub permissions: PermissionFlags,
pub managed: bool, pub managed: bool,
@ -47,11 +48,13 @@ 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,
pub total_months_subscribed: u32, pub total_months_subscribed: UInt32,
pub is_renewal: bool, pub is_renewal: bool,
} }
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, Hash, Copy, PartialOrd, Ord)] #[derive(
Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, Hash, Copy, PartialOrd, Ord,
)]
/// See <https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure> /// See <https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure>
pub struct RoleTags { pub struct RoleTags {
#[serde(default)] #[serde(default)]

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,7 +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,
pub counter: u64, pub counter: UInt64,
pub name: String, pub name: String,
} }
@ -24,7 +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(),
counter: 0, #[allow(clippy::useless_conversion)]
counter: 0u64.into(),
name: String::new(), name: String::new(),
} }
} }

View File

@ -21,8 +21,11 @@ pub struct StageInstance {
pub guild_scheduled_event_id: Option<Snowflake>, pub guild_scheduled_event_id: Option<Snowflake>,
} }
#[derive(Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord)] #[derive(
#[repr(u8)] Serialize_repr, Deserialize_repr, Debug, Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord,
)]
#[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
/// See <https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level> /// See <https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-privacy-level>
pub enum StageInstancePrivacyLevel { pub enum StageInstancePrivacyLevel {

View File

@ -77,7 +77,8 @@ pub struct StickerItem {
#[derive( #[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename = "SCREAMING_SNAKE_CASE")] #[serde(rename = "SCREAMING_SNAKE_CASE")]
/// # Reference /// # Reference
@ -93,7 +94,8 @@ pub enum StickerType {
#[derive( #[derive(
Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
/// # Reference /// # Reference
/// See <https://docs.discord.sex/resources/sticker#sticker-format-types> /// See <https://docs.discord.sex/resources/sticker#sticker-format-types>

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,7 +35,7 @@ impl PartialEq for Team {
#[derive(Debug, Deserialize, Serialize, Clone)] #[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TeamMember { pub struct TeamMember {
pub membership_state: u8, pub membership_state: UInt8,
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

@ -6,10 +6,11 @@ use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::{ use crate::types::{
Shared,
entities::{Guild, User}, entities::{Guild, User},
utils::Snowflake, utils::Snowflake,
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,7 +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>,
pub usage_count: Option<u64>, pub usage_count: Option<UInt64>,
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,7 +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>,
pub accent_color: Option<u32>, pub accent_color: Option<UInt32>,
#[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>,
@ -58,7 +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>>,
pub premium_type: Option<u8>, pub premium_type: Option<UInt8>,
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>,
@ -109,32 +110,32 @@ impl TryFrom<Vec<u8>> for ThemeColors {
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
// TODO: Add tests for Encode and Decode. // TODO: Add tests for Encode and Decode.
impl<'q> sqlx::Encode<'q, sqlx::Any> for ThemeColors { impl<'q> sqlx::Encode<'q, sqlx::Postgres> for ThemeColors {
fn encode_by_ref( fn encode_by_ref(
&self, &self,
buf: &mut <sqlx::Any as sqlx::Database>::ArgumentBuffer<'q>, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync>> { ) -> Result<sqlx::encode::IsNull, Box<dyn std::error::Error + Send + Sync>> {
let mut vec_u8 = Vec::new(); let mut vec_u8 = Vec::new();
vec_u8.extend_from_slice(&self.inner.0.to_be_bytes()); vec_u8.extend_from_slice(&self.inner.0.to_be_bytes());
vec_u8.extend_from_slice(&self.inner.1.to_be_bytes()); vec_u8.extend_from_slice(&self.inner.1.to_be_bytes());
<Vec<u8> as sqlx::Encode<sqlx::Any>>::encode_by_ref(&vec_u8, buf) <Vec<u8> as sqlx::Encode<sqlx::Postgres>>::encode_by_ref(&vec_u8, buf)
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'d> sqlx::Decode<'d, sqlx::Any> for ThemeColors { impl<'d> sqlx::Decode<'d, sqlx::Postgres> for ThemeColors {
fn decode( fn decode(
value: <sqlx::Any as sqlx::Database>::ValueRef<'d>, value: <sqlx::Postgres as sqlx::Database>::ValueRef<'d>,
) -> Result<Self, sqlx::error::BoxDynError> { ) -> Result<Self, sqlx::error::BoxDynError> {
let value_vec = <Vec<u8> as sqlx::Decode<'d, sqlx::Any>>::decode(value)?; let value_vec = <Vec<u8> as sqlx::Decode<'d, sqlx::Postgres>>::decode(value)?;
value_vec.try_into().map_err(|e: ChorusError| e.into()) value_vec.try_into().map_err(|e: ChorusError| e.into())
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl sqlx::Type<sqlx::Any> for ThemeColors { impl sqlx::Type<sqlx::Postgres> for ThemeColors {
fn type_info() -> <sqlx::Any as sqlx::Database>::TypeInfo { fn type_info() -> <sqlx::Postgres as sqlx::Database>::TypeInfo {
<String as sqlx::Type<sqlx::Any>>::type_info() <String as sqlx::Type<sqlx::Postgres>>::type_info()
} }
} }
@ -144,13 +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>,
pub accent_color: Option<u32>, pub accent_color: Option<UInt32>,
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>,
pub premium_type: Option<u8>, pub premium_type: Option<UInt8>,
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,9 +6,12 @@ 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(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default, Copy, PartialOrd, Ord, Hash)] #[derive(
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default, Copy, PartialOrd, Ord, Hash,
)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum UserStatus { pub enum UserStatus {
@ -26,7 +29,9 @@ impl std::fmt::Display for UserStatus {
} }
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default, Copy, PartialOrd, Ord, Hash)] #[derive(
Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default, Copy, PartialOrd, Ord, Hash,
)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum UserTheme { pub enum UserTheme {
@ -38,36 +43,23 @@ 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 {
pub afk_timeout: Option<u16>, pub afk_timeout: Option<UInt16>,
pub allow_accessibility_detection: bool, pub allow_accessibility_detection: bool,
pub animate_emoji: bool, pub animate_emoji: bool,
pub animate_stickers: u8, pub animate_stickers: UInt8,
pub contact_sync_enabled: bool, pub contact_sync_enabled: bool,
pub convert_emoticons: bool, pub convert_emoticons: bool,
#[cfg(feature = "sqlx")]
pub custom_status: Option<sqlx::types::Json<CustomStatus>>,
#[cfg(not(feature = "sqlx"))]
pub custom_status: Option<CustomStatus>, pub custom_status: Option<CustomStatus>,
pub default_guilds_restricted: bool, pub default_guilds_restricted: bool,
pub detect_platform_accounts: bool, pub detect_platform_accounts: bool,
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,
pub explicit_content_filter: u8, pub explicit_content_filter: UInt8,
#[cfg(feature = "sqlx")]
pub friend_source_flags: sqlx::types::Json<FriendSourceFlags>,
#[cfg(not(feature = "sqlx"))]
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,
#[cfg(feature = "sqlx")]
pub guild_folders: sqlx::types::Json<Vec<GuildFolder>>,
#[cfg(not(feature = "sqlx"))]
pub guild_folders: Vec<GuildFolder>, pub guild_folders: Vec<GuildFolder>,
#[cfg(feature = "sqlx")]
#[serde(default)]
pub guild_positions: sqlx::types::Json<Vec<String>>,
#[cfg(not(feature = "sqlx"))]
#[serde(default)] #[serde(default)]
pub guild_positions: Vec<String>, pub guild_positions: Vec<String>,
pub inline_attachment_media: bool, pub inline_attachment_media: bool,
@ -77,9 +69,6 @@ pub struct UserSettings {
pub native_phone_integration_enabled: bool, pub native_phone_integration_enabled: bool,
pub render_embeds: bool, pub render_embeds: bool,
pub render_reactions: bool, pub render_reactions: bool,
#[cfg(feature = "sqlx")]
pub restricted_guilds: sqlx::types::Json<Vec<String>>,
#[cfg(not(feature = "sqlx"))]
pub restricted_guilds: Vec<String>, pub restricted_guilds: Vec<String>,
pub show_current_game: bool, pub show_current_game: bool,
pub status: Shared<UserStatus>, pub status: Shared<UserStatus>,
@ -91,10 +80,14 @@ pub struct UserSettings {
impl Default for UserSettings { impl Default for UserSettings {
fn default() -> Self { fn default() -> Self {
Self { Self {
afk_timeout: Some(3600), #[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"))]
animate_stickers: 0, animate_stickers: 0,
#[cfg(feature = "sqlx")]
animate_stickers: 0.into(),
contact_sync_enabled: false, contact_sync_enabled: false,
convert_emoticons: false, convert_emoticons: false,
custom_status: None, custom_status: None,
@ -103,7 +96,10 @@ impl Default for UserSettings {
developer_mode: true, developer_mode: true,
disable_games_tab: true, disable_games_tab: true,
enable_tts_command: false, enable_tts_command: false,
#[cfg(not(feature = "sqlx"))]
explicit_content_filter: 0, explicit_content_filter: 0,
#[cfg(feature = "sqlx")]
explicit_content_filter: 0.into(),
friend_source_flags: Default::default(), friend_source_flags: Default::default(),
gateway_connected: Some(false), gateway_connected: Some(false),
gif_auto_play: false, gif_auto_play: false,
@ -127,7 +123,8 @@ impl Default for UserSettings {
} }
#[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, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct CustomStatus { pub struct CustomStatus {
pub emoji_id: Option<String>, pub emoji_id: Option<String>,
pub emoji_name: Option<String>, pub emoji_name: Option<String>,
@ -137,6 +134,7 @@ pub struct CustomStatus {
} }
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Copy, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
pub struct FriendSourceFlags { pub struct FriendSourceFlags {
pub all: bool, pub all: bool,
} }
@ -148,8 +146,10 @@ impl Default for FriendSourceFlags {
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "sqlx", derive(sqlx::FromRow, sqlx::Type))]
#[cfg_attr(feature = "sqlx", sqlx(type_name = "interface_type"))]
pub struct GuildFolder { pub struct GuildFolder {
pub color: Option<u32>, pub color: Option<UInt32>,
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.

View File

@ -71,7 +71,8 @@ impl PartialEq for Webhook {
#[derive( #[derive(
Serialize, Deserialize, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
)] )]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
pub enum WebhookType { pub enum WebhookType {
#[default] #[default]

View File

@ -5,7 +5,7 @@
use bitflags::bitflags; use bitflags::bitflags;
use serde::{Deserialize, Serialize}; 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)] #[derive(Debug, Deserialize, Serialize, Default, PartialEq, PartialOrd)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
@ -141,7 +141,8 @@ bitflags! {
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum InviteType { pub enum InviteType {
#[default] #[default]
Guild = 0, Guild = 0,
@ -152,7 +153,8 @@ pub enum InviteType {
#[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)] #[derive(Debug, Deserialize, Serialize, Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq)]
#[cfg_attr(feature = "sqlx", derive(sqlx::Type))] #[cfg_attr(feature = "sqlx", derive(sqlx::Type))]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")] #[serde(rename_all = "SCREAMING_SNAKE_CASE")]
#[repr(u8)] #[cfg_attr(not(feature = "sqlx"), repr(u8))]
#[cfg_attr(feature = "sqlx", repr(i16))]
pub enum InviteTargetType { pub enum InviteTargetType {
#[default] #[default]
Stream = 1, Stream = 1,
@ -169,7 +171,9 @@ pub struct AddChannelRecipientSchema {
} }
/// See <https://discord-userdoccers.vercel.app/resources/channel#add-channel-recipient> /// 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 struct ModifyChannelPositionsSchema {
pub id: Snowflake, pub id: Snowflake,
pub position: Option<u32>, pub position: Option<u32>,
@ -178,7 +182,9 @@ pub struct ModifyChannelPositionsSchema {
} }
/// See <https://docs.discord.sex/resources/channel#follow-channel> /// 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 struct AddFollowingChannelSchema {
pub webhook_channel_id: Snowflake, pub webhook_channel_id: Snowflake,
} }

View File

@ -53,12 +53,9 @@ impl Display for Snowflake {
} }
} }
impl<T> From<T> for Snowflake impl From<u64> for Snowflake {
where fn from(item: u64) -> Self {
T: Into<u64>, Self(item)
{
fn from(item: T) -> Self {
Self(item.into())
} }
} }
@ -99,28 +96,35 @@ impl<'de> serde::Deserialize<'de> for Snowflake {
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl sqlx::Type<sqlx::Any> for Snowflake { impl sqlx::Type<sqlx::Postgres> for Snowflake {
fn type_info() -> <sqlx::Any as sqlx::Database>::TypeInfo { fn type_info() -> <sqlx::Postgres as sqlx::Database>::TypeInfo {
<String as sqlx::Type<sqlx::Any>>::type_info() <String as sqlx::Type<sqlx::Postgres>>::type_info()
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'q> sqlx::Encode<'q, sqlx::Any> for Snowflake { impl sqlx::postgres::PgHasArrayType for Snowflake {
fn array_type_info() -> sqlx::postgres::PgTypeInfo {
<Vec<String> as sqlx::Type<sqlx::Postgres>>::type_info()
}
}
#[cfg(feature = "sqlx")]
impl<'q> sqlx::Encode<'q, sqlx::Postgres> for Snowflake {
fn encode_by_ref( fn encode_by_ref(
&self, &self,
buf: &mut <sqlx::Any as sqlx::Database>::ArgumentBuffer<'q>, buf: &mut <sqlx::Postgres as sqlx::Database>::ArgumentBuffer<'q>,
) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> {
<String as sqlx::Encode<'q, sqlx::Any>>::encode_by_ref(&self.0.to_string(), buf) <String as sqlx::Encode<'q, sqlx::Postgres>>::encode_by_ref(&self.0.to_string(), buf)
} }
} }
#[cfg(feature = "sqlx")] #[cfg(feature = "sqlx")]
impl<'d> sqlx::Decode<'d, sqlx::Any> for Snowflake { impl<'d> sqlx::Decode<'d, sqlx::Postgres> for Snowflake {
fn decode( fn decode(
value: <sqlx::Any as sqlx::Database>::ValueRef<'d>, value: <sqlx::Postgres as sqlx::Database>::ValueRef<'d>,
) -> Result<Self, sqlx::error::BoxDynError> { ) -> Result<Self, sqlx::error::BoxDynError> {
<String as sqlx::Decode<'d, sqlx::Any>>::decode(value) <String as sqlx::Decode<'d, sqlx::Postgres>>::decode(value)
.map(|s| s.parse::<u64>().map(Snowflake).unwrap()) .map(|s| s.parse::<u64>().map(Snowflake).unwrap())
} }
} }