From: Matthieu Date: Fri, 5 Nov 2021 15:04:58 +0000 (+0400) Subject: use twilight for deserialization and gateway X-Git-Tag: v0.1~47^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=7ddb5d3820c15ce4202e6f43057310a9fbb7178a;p=matthieu%2Fnova.git use twilight for deserialization and gateway --- diff --git a/Cargo.lock b/Cargo.lock index d68741b..f7454bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,9 +213,11 @@ dependencies = [ "prometheus", "redis", "serde 1.0.130", + "serde_json", "serde_repr", "testcontainers", "tokio", + "twilight-model", ] [[package]] @@ -313,6 +315,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "ct-logs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" +dependencies = [ + "sct", +] + [[package]] name = "ctor" version = "0.1.21" @@ -438,6 +449,7 @@ dependencies = [ "cfg-if", "crc32fast", "libc", + "libz-sys", "miniz_oxide", ] @@ -586,18 +598,11 @@ name = "gateway" version = "0.1.0" dependencies = [ "common", - "enumflags2", "futures", - "futures-util", - "num", - "num-derive", - "num-traits 0.2.14", "serde 1.0.130", "serde_json", - "serde_repr", "tokio", - "tokio-tungstenite", - "url", + "twilight-gateway", ] [[package]] @@ -749,6 +754,23 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +dependencies = [ + "ct-logs", + "futures-util", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "webpki", +] + [[package]] name = "hyper-tls" version = "0.5.0" @@ -783,6 +805,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "input_buffer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" +dependencies = [ + "bytes", +] + [[package]] name = "instant" version = "0.1.12" @@ -838,6 +869,17 @@ version = "0.2.104" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" +[[package]] +name = "libz-sys" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -1005,51 +1047,6 @@ dependencies = [ "rand 0.8.4", ] -[[package]] -name = "num" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits 0.2.14", -] - -[[package]] -name = "num-bigint" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535" -dependencies = [ - "autocfg", - "num-integer", - "num-traits 0.2.14", -] - -[[package]] -name = "num-complex" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" -dependencies = [ - "num-traits 0.2.14", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "num-integer" version = "0.1.44" @@ -1060,29 +1057,6 @@ dependencies = [ "num-traits 0.2.14", ] -[[package]] -name = "num-iter" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" -dependencies = [ - "autocfg", - "num-integer", - "num-traits 0.2.14", -] - -[[package]] -name = "num-rational" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits 0.2.14", -] - [[package]] name = "num-traits" version = "0.1.43" @@ -1156,6 +1130,15 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "ordered-float" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97c9d06878b3a851e8026ef94bf7fef9ba93062cd412601da4d9cf369b1cc62d" +dependencies = [ + "num-traits 0.2.14", +] + [[package]] name = "parking" version = "2.0.0" @@ -1602,6 +1585,16 @@ dependencies = [ "serde 0.8.23", ] +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde 1.0.130", +] + [[package]] name = "serde_derive" version = "1.0.130" @@ -1904,9 +1897,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.15.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8" +checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2" dependencies = [ "futures-util", "log", @@ -1956,9 +1949,21 @@ checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.21" @@ -1976,24 +1981,86 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "tungstenite" -version = "0.14.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5" +checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093" dependencies = [ "base64", "byteorder", "bytes", "http", "httparse", + "input_buffer", "log", "rand 0.8.4", "rustls", - "rustls-native-certs", "sha-1", "thiserror", "url", "utf-8", "webpki", + "webpki-roots", +] + +[[package]] +name = "twilight-gateway" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d0495761099f21c92050486717b3ccd8b3cd137626a511c0694d32edd92511b" +dependencies = [ + "bitflags", + "flate2", + "futures-util", + "once_cell", + "serde 1.0.130", + "serde_json", + "tokio", + "tokio-tungstenite", + "tracing", + "twilight-gateway-queue", + "twilight-http", + "twilight-model", + "url", +] + +[[package]] +name = "twilight-gateway-queue" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f45ea68d917d5fbbfe739be9ace81d6824518262feb7a9139552bab64811f5a" +dependencies = [ + "tokio", + "tracing", + "twilight-http", +] + +[[package]] +name = "twilight-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ef176da0d6a25e7f6b69d6efddacc215ac62313596047566726360ec6cf438" +dependencies = [ + "hyper", + "hyper-rustls", + "percent-encoding", + "rand 0.8.4", + "serde 1.0.130", + "serde_json", + "tokio", + "twilight-model", +] + +[[package]] +name = "twilight-model" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d27af7e29d24bdf4f7e2511b36cc571fb5613b5ca5726ca0da36f55d76668a" +dependencies = [ + "bitflags", + "serde 1.0.130", + "serde-value", + "serde_repr", + "tracing", ] [[package]] @@ -2166,6 +2233,7 @@ dependencies = [ "serde 1.0.130", "serde_json", "tokio", + "twilight-model", ] [[package]] diff --git a/cargo/crates.bzl b/cargo/crates.bzl index 5d2dd87..1a9825d 100644 --- a/cargo/crates.bzl +++ b/cargo/crates.bzl @@ -21,6 +21,7 @@ _DEPENDENCIES = { "serde": "@raze__serde__1_0_130//:serde", "serde_json": "@raze__serde_json__1_0_68//:serde_json", "tokio": "@raze__tokio__1_12_0//:tokio", + "twilight-model": "@raze__twilight_model__0_6_5//:twilight_model", }, "common/rust": { "config": "@raze__config__0_11_0//:config", @@ -32,20 +33,17 @@ _DEPENDENCIES = { "prometheus": "@raze__prometheus__0_12_0//:prometheus", "redis": "@raze__redis__0_21_3//:redis", "serde": "@raze__serde__1_0_130//:serde", + "serde_json": "@raze__serde_json__1_0_68//:serde_json", "testcontainers": "@raze__testcontainers__0_12_0//:testcontainers", "tokio": "@raze__tokio__1_12_0//:tokio", + "twilight-model": "@raze__twilight_model__0_6_5//:twilight_model", }, "gateway": { - "enumflags2": "@raze__enumflags2__0_7_1//:enumflags2", "futures": "@raze__futures__0_3_17//:futures", - "futures-util": "@raze__futures_util__0_3_17//:futures_util", - "num": "@raze__num__0_4_0//:num", - "num-traits": "@raze__num_traits__0_2_14//:num_traits", "serde": "@raze__serde__1_0_130//:serde", "serde_json": "@raze__serde_json__1_0_68//:serde_json", "tokio": "@raze__tokio__1_12_0//:tokio", - "tokio-tungstenite": "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite", - "url": "@raze__url__2_2_2//:url", + "twilight-gateway": "@raze__twilight_gateway__0_6_5//:twilight_gateway", }, "cache": { "log": "@raze__log__0_4_14//:log", @@ -77,8 +75,6 @@ _PROC_MACRO_DEPENDENCIES = { "serde_repr": "@raze__serde_repr__0_1_7//:serde_repr", }, "gateway": { - "num-derive": "@raze__num_derive__0_3_3//:num_derive", - "serde_repr": "@raze__serde_repr__0_1_7//:serde_repr", }, "cache": { }, @@ -585,6 +581,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.crypto-mac-0.10.1.bazel"), ) + maybe( + http_archive, + name = "raze__ct_logs__0_8_0", + url = "https://crates.io/api/v1/crates/ct-logs/0.8.0/download", + type = "tar.gz", + sha256 = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8", + strip_prefix = "ct-logs-0.8.0", + build_file = Label("//cargo/remote:BUILD.ct-logs-0.8.0.bazel"), + ) + maybe( http_archive, name = "raze__ctor__0_1_21", @@ -995,6 +1001,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.hyper-0.14.13.bazel"), ) + maybe( + http_archive, + name = "raze__hyper_rustls__0_22_1", + url = "https://crates.io/api/v1/crates/hyper-rustls/0.22.1/download", + type = "tar.gz", + sha256 = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64", + strip_prefix = "hyper-rustls-0.22.1", + build_file = Label("//cargo/remote:BUILD.hyper-rustls-0.22.1.bazel"), + ) + maybe( http_archive, name = "raze__hyper_tls__0_5_0", @@ -1025,6 +1041,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.indexmap-1.7.0.bazel"), ) + maybe( + http_archive, + name = "raze__input_buffer__0_4_0", + url = "https://crates.io/api/v1/crates/input_buffer/0.4.0/download", + type = "tar.gz", + sha256 = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413", + strip_prefix = "input_buffer-0.4.0", + build_file = Label("//cargo/remote:BUILD.input_buffer-0.4.0.bazel"), + ) + maybe( http_archive, name = "raze__instant__0_1_12", @@ -1095,6 +1121,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.libc-0.2.104.bazel"), ) + maybe( + http_archive, + name = "raze__libz_sys__1_1_3", + url = "https://crates.io/api/v1/crates/libz-sys/1.1.3/download", + type = "tar.gz", + sha256 = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66", + strip_prefix = "libz-sys-1.1.3", + build_file = Label("//cargo/remote:BUILD.libz-sys-1.1.3.bazel"), + ) + maybe( http_archive, name = "raze__linked_hash_map__0_5_4", @@ -1235,46 +1271,6 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.nuid-0.3.0.bazel"), ) - maybe( - http_archive, - name = "raze__num__0_4_0", - url = "https://crates.io/api/v1/crates/num/0.4.0/download", - type = "tar.gz", - sha256 = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606", - strip_prefix = "num-0.4.0", - build_file = Label("//cargo/remote:BUILD.num-0.4.0.bazel"), - ) - - maybe( - http_archive, - name = "raze__num_bigint__0_4_2", - url = "https://crates.io/api/v1/crates/num-bigint/0.4.2/download", - type = "tar.gz", - sha256 = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535", - strip_prefix = "num-bigint-0.4.2", - build_file = Label("//cargo/remote:BUILD.num-bigint-0.4.2.bazel"), - ) - - maybe( - http_archive, - name = "raze__num_complex__0_4_0", - url = "https://crates.io/api/v1/crates/num-complex/0.4.0/download", - type = "tar.gz", - sha256 = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085", - strip_prefix = "num-complex-0.4.0", - build_file = Label("//cargo/remote:BUILD.num-complex-0.4.0.bazel"), - ) - - maybe( - http_archive, - name = "raze__num_derive__0_3_3", - url = "https://crates.io/api/v1/crates/num-derive/0.3.3/download", - type = "tar.gz", - sha256 = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d", - strip_prefix = "num-derive-0.3.3", - build_file = Label("//cargo/remote:BUILD.num-derive-0.3.3.bazel"), - ) - maybe( http_archive, name = "raze__num_integer__0_1_44", @@ -1285,26 +1281,6 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.num-integer-0.1.44.bazel"), ) - maybe( - http_archive, - name = "raze__num_iter__0_1_42", - url = "https://crates.io/api/v1/crates/num-iter/0.1.42/download", - type = "tar.gz", - sha256 = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59", - strip_prefix = "num-iter-0.1.42", - build_file = Label("//cargo/remote:BUILD.num-iter-0.1.42.bazel"), - ) - - maybe( - http_archive, - name = "raze__num_rational__0_4_0", - url = "https://crates.io/api/v1/crates/num-rational/0.4.0/download", - type = "tar.gz", - sha256 = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a", - strip_prefix = "num-rational-0.4.0", - build_file = Label("//cargo/remote:BUILD.num-rational-0.4.0.bazel"), - ) - maybe( http_archive, name = "raze__num_traits__0_1_43", @@ -1385,6 +1361,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.openssl-sys-0.9.67.bazel"), ) + maybe( + http_archive, + name = "raze__ordered_float__2_8_0", + url = "https://crates.io/api/v1/crates/ordered-float/2.8.0/download", + type = "tar.gz", + sha256 = "97c9d06878b3a851e8026ef94bf7fef9ba93062cd412601da4d9cf369b1cc62d", + strip_prefix = "ordered-float-2.8.0", + build_file = Label("//cargo/remote:BUILD.ordered-float-2.8.0.bazel"), + ) + maybe( http_archive, name = "raze__parking__2_0_0", @@ -1835,6 +1821,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.serde-hjson-0.9.1.bazel"), ) + maybe( + http_archive, + name = "raze__serde_value__0_7_0", + url = "https://crates.io/api/v1/crates/serde-value/0.7.0/download", + type = "tar.gz", + sha256 = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c", + strip_prefix = "serde-value-0.7.0", + build_file = Label("//cargo/remote:BUILD.serde-value-0.7.0.bazel"), + ) + maybe( http_archive, name = "raze__serde_derive__1_0_130", @@ -2137,12 +2133,12 @@ def raze_fetch_remote_crates(): maybe( http_archive, - name = "raze__tokio_tungstenite__0_15_0", - url = "https://crates.io/api/v1/crates/tokio-tungstenite/0.15.0/download", + name = "raze__tokio_tungstenite__0_14_0", + url = "https://crates.io/api/v1/crates/tokio-tungstenite/0.14.0/download", type = "tar.gz", - sha256 = "511de3f85caf1c98983545490c3d09685fa8eb634e57eec22bb4db271f46cbd8", - strip_prefix = "tokio-tungstenite-0.15.0", - build_file = Label("//cargo/remote:BUILD.tokio-tungstenite-0.15.0.bazel"), + sha256 = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2", + strip_prefix = "tokio-tungstenite-0.14.0", + build_file = Label("//cargo/remote:BUILD.tokio-tungstenite-0.14.0.bazel"), ) maybe( @@ -2185,6 +2181,16 @@ def raze_fetch_remote_crates(): build_file = Label("//cargo/remote:BUILD.tracing-0.1.29.bazel"), ) + maybe( + http_archive, + name = "raze__tracing_attributes__0_1_18", + url = "https://crates.io/api/v1/crates/tracing-attributes/0.1.18/download", + type = "tar.gz", + sha256 = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e", + strip_prefix = "tracing-attributes-0.1.18", + build_file = Label("//cargo/remote:BUILD.tracing-attributes-0.1.18.bazel"), + ) + maybe( http_archive, name = "raze__tracing_core__0_1_21", @@ -2207,12 +2213,52 @@ def raze_fetch_remote_crates(): maybe( http_archive, - name = "raze__tungstenite__0_14_0", - url = "https://crates.io/api/v1/crates/tungstenite/0.14.0/download", + name = "raze__tungstenite__0_13_0", + url = "https://crates.io/api/v1/crates/tungstenite/0.13.0/download", + type = "tar.gz", + sha256 = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093", + strip_prefix = "tungstenite-0.13.0", + build_file = Label("//cargo/remote:BUILD.tungstenite-0.13.0.bazel"), + ) + + maybe( + http_archive, + name = "raze__twilight_gateway__0_6_5", + url = "https://crates.io/api/v1/crates/twilight-gateway/0.6.5/download", + type = "tar.gz", + sha256 = "3d0495761099f21c92050486717b3ccd8b3cd137626a511c0694d32edd92511b", + strip_prefix = "twilight-gateway-0.6.5", + build_file = Label("//cargo/remote:BUILD.twilight-gateway-0.6.5.bazel"), + ) + + maybe( + http_archive, + name = "raze__twilight_gateway_queue__0_6_0", + url = "https://crates.io/api/v1/crates/twilight-gateway-queue/0.6.0/download", + type = "tar.gz", + sha256 = "5f45ea68d917d5fbbfe739be9ace81d6824518262feb7a9139552bab64811f5a", + strip_prefix = "twilight-gateway-queue-0.6.0", + build_file = Label("//cargo/remote:BUILD.twilight-gateway-queue-0.6.0.bazel"), + ) + + maybe( + http_archive, + name = "raze__twilight_http__0_6_6", + url = "https://crates.io/api/v1/crates/twilight-http/0.6.6/download", + type = "tar.gz", + sha256 = "08ef176da0d6a25e7f6b69d6efddacc215ac62313596047566726360ec6cf438", + strip_prefix = "twilight-http-0.6.6", + build_file = Label("//cargo/remote:BUILD.twilight-http-0.6.6.bazel"), + ) + + maybe( + http_archive, + name = "raze__twilight_model__0_6_5", + url = "https://crates.io/api/v1/crates/twilight-model/0.6.5/download", type = "tar.gz", - sha256 = "a0b2d8558abd2e276b0a8df5c05a2ec762609344191e5fd23e292c910e9165b5", - strip_prefix = "tungstenite-0.14.0", - build_file = Label("//cargo/remote:BUILD.tungstenite-0.14.0.bazel"), + sha256 = "d7d27af7e29d24bdf4f7e2511b36cc571fb5613b5ca5726ca0da36f55d76668a", + strip_prefix = "twilight-model-0.6.5", + build_file = Label("//cargo/remote:BUILD.twilight-model-0.6.5.bazel"), ) maybe( diff --git a/cargo/remote/BUILD.ct-logs-0.8.0.bazel b/cargo/remote/BUILD.ct-logs-0.8.0.bazel new file mode 100644 index 0000000..4045ffa --- /dev/null +++ b/cargo/remote/BUILD.ct-logs-0.8.0.bazel @@ -0,0 +1,54 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # Apache-2.0 from expression "Apache-2.0 OR (ISC OR MIT)" +]) + +# Generated Targets + +rust_library( + name = "ct_logs", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.8.0", + # buildifier: leave-alone + deps = [ + "@raze__sct__0_6_1//:sct", + ], +) diff --git a/cargo/remote/BUILD.flate2-1.0.22.bazel b/cargo/remote/BUILD.flate2-1.0.22.bazel index b90354e..dc36758 100644 --- a/cargo/remote/BUILD.flate2-1.0.22.bazel +++ b/cargo/remote/BUILD.flate2-1.0.22.bazel @@ -80,9 +80,12 @@ rust_library( aliases = { }, crate_features = [ + "any_zlib", "default", + "libz-sys", "miniz_oxide", "rust_backend", + "zlib", ], crate_root = "src/lib.rs", crate_type = "lib", @@ -102,6 +105,7 @@ rust_library( "@raze__cfg_if__1_0_0//:cfg_if", "@raze__crc32fast__1_2_1//:crc32fast", "@raze__libc__0_2_104//:libc", + "@raze__libz_sys__1_1_3//:libz_sys", "@raze__miniz_oxide__0_4_4//:miniz_oxide", ] + selects.with_or({ # cfg(all(target_arch = "wasm32", not(target_os = "emscripten"))) diff --git a/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel b/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel new file mode 100644 index 0000000..fa0faf8 --- /dev/null +++ b/cargo/remote/BUILD.hyper-rustls-0.22.1.bazel @@ -0,0 +1,72 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # Apache-2.0 from expression "Apache-2.0 OR (ISC OR MIT)" +]) + +# Generated Targets + +# Unsupported target "client" with type "example" omitted + +# Unsupported target "server" with type "example" omitted + +rust_library( + name = "hyper_rustls", + srcs = glob(["**/*.rs"]), + crate_features = [ + "ct-logs", + "native-tokio", + "rustls-native-certs", + "tokio-runtime", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.22.1", + # buildifier: leave-alone + deps = [ + "@raze__ct_logs__0_8_0//:ct_logs", + "@raze__futures_util__0_3_17//:futures_util", + "@raze__hyper__0_14_13//:hyper", + "@raze__log__0_4_14//:log", + "@raze__rustls__0_19_1//:rustls", + "@raze__rustls_native_certs__0_5_0//:rustls_native_certs", + "@raze__tokio__1_12_0//:tokio", + "@raze__tokio_rustls__0_22_0//:tokio_rustls", + "@raze__webpki__0_21_4//:webpki", + ], +) + +# Unsupported target "tests" with type "test" omitted diff --git a/cargo/remote/BUILD.input_buffer-0.4.0.bazel b/cargo/remote/BUILD.input_buffer-0.4.0.bazel new file mode 100644 index 0000000..e59c53a --- /dev/null +++ b/cargo/remote/BUILD.input_buffer-0.4.0.bazel @@ -0,0 +1,54 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "input_buffer", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + # buildifier: leave-alone + deps = [ + "@raze__bytes__1_1_0//:bytes", + ], +) diff --git a/cargo/remote/BUILD.libz-sys-1.1.3.bazel b/cargo/remote/BUILD.libz-sys-1.1.3.bazel new file mode 100644 index 0000000..459fa37 --- /dev/null +++ b/cargo/remote/BUILD.libz-sys-1.1.3.bazel @@ -0,0 +1,105 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "libz_sys_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + links = "z", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.1.3", + visibility = ["//visibility:private"], + deps = [ + "@raze__cc__1_0_71//:cc", + "@raze__pkg_config__0_3_20//:pkg_config", + ] + selects.with_or({ + # cfg(target_env = "msvc") + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@raze__vcpkg__0_2_15//:vcpkg", + ], + "//conditions:default": [], + }), +) + +rust_library( + name = "libz_sys", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "1.1.3", + # buildifier: leave-alone + deps = [ + ":libz_sys_build_script", + ] + selects.with_or({ + # cfg(target_env = "msvc") + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + ], + "//conditions:default": [], + }), +) diff --git a/cargo/remote/BUILD.num-0.4.0.bazel b/cargo/remote/BUILD.num-0.4.0.bazel deleted file mode 100644 index 8409859..0000000 --- a/cargo/remote/BUILD.num-0.4.0.bazel +++ /dev/null @@ -1,62 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets - -rust_library( - name = "num", - srcs = glob(["**/*.rs"]), - crate_features = [ - "default", - "num-bigint", - "std", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.0", - # buildifier: leave-alone - deps = [ - "@raze__num_bigint__0_4_2//:num_bigint", - "@raze__num_complex__0_4_0//:num_complex", - "@raze__num_integer__0_1_44//:num_integer", - "@raze__num_iter__0_1_42//:num_iter", - "@raze__num_rational__0_4_0//:num_rational", - "@raze__num_traits__0_2_14//:num_traits", - ], -) diff --git a/cargo/remote/BUILD.num-bigint-0.4.2.bazel b/cargo/remote/BUILD.num-bigint-0.4.2.bazel deleted file mode 100644 index eb2b157..0000000 --- a/cargo/remote/BUILD.num-bigint-0.4.2.bazel +++ /dev/null @@ -1,112 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets -# buildifier: disable=out-of-order-load -# buildifier: disable=load-on-top -load( - "@rules_rust//cargo:cargo_build_script.bzl", - "cargo_build_script", -) - -cargo_build_script( - name = "num_bigint_build_script", - srcs = glob(["**/*.rs"]), - build_script_env = { - }, - crate_features = [ - "std", - ], - crate_root = "build.rs", - data = glob(["**"]), - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.2", - visibility = ["//visibility:private"], - deps = [ - "@raze__autocfg__1_0_1//:autocfg", - ], -) - -# Unsupported target "bigint" with type "bench" omitted - -# Unsupported target "factorial" with type "bench" omitted - -# Unsupported target "gcd" with type "bench" omitted - -# Unsupported target "roots" with type "bench" omitted - -# Unsupported target "shootout-pidigits" with type "bench" omitted - -rust_library( - name = "num_bigint", - srcs = glob(["**/*.rs"]), - crate_features = [ - "std", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.2", - # buildifier: leave-alone - deps = [ - ":num_bigint_build_script", - "@raze__num_integer__0_1_44//:num_integer", - "@raze__num_traits__0_2_14//:num_traits", - ], -) - -# Unsupported target "bigint" with type "test" omitted - -# Unsupported target "bigint_bitwise" with type "test" omitted - -# Unsupported target "bigint_scalar" with type "test" omitted - -# Unsupported target "biguint" with type "test" omitted - -# Unsupported target "biguint_scalar" with type "test" omitted - -# Unsupported target "modpow" with type "test" omitted - -# Unsupported target "roots" with type "test" omitted diff --git a/cargo/remote/BUILD.num-complex-0.4.0.bazel b/cargo/remote/BUILD.num-complex-0.4.0.bazel deleted file mode 100644 index 4e32b7b..0000000 --- a/cargo/remote/BUILD.num-complex-0.4.0.bazel +++ /dev/null @@ -1,55 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets - -rust_library( - name = "num_complex", - srcs = glob(["**/*.rs"]), - crate_features = [ - "std", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.0", - # buildifier: leave-alone - deps = [ - "@raze__num_traits__0_2_14//:num_traits", - ], -) diff --git a/cargo/remote/BUILD.num-derive-0.3.3.bazel b/cargo/remote/BUILD.num-derive-0.3.3.bazel deleted file mode 100644 index cf86c8d..0000000 --- a/cargo/remote/BUILD.num-derive-0.3.3.bazel +++ /dev/null @@ -1,74 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets - -rust_library( - name = "num_derive", - srcs = glob(["**/*.rs"]), - crate_features = [ - ], - crate_root = "src/lib.rs", - crate_type = "proc-macro", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.3.3", - # buildifier: leave-alone - deps = [ - "@raze__proc_macro2__1_0_30//:proc_macro2", - "@raze__quote__1_0_10//:quote", - "@raze__syn__1_0_80//:syn", - ], -) - -# Unsupported target "empty_enum" with type "test" omitted - -# Unsupported target "issue-6" with type "test" omitted - -# Unsupported target "issue-9" with type "test" omitted - -# Unsupported target "newtype" with type "test" omitted - -# Unsupported target "newtype-2015" with type "test" omitted - -# Unsupported target "num_derive_without_num" with type "test" omitted - -# Unsupported target "trivial" with type "test" omitted - -# Unsupported target "trivial-2015" with type "test" omitted - -# Unsupported target "with_custom_values" with type "test" omitted diff --git a/cargo/remote/BUILD.num-integer-0.1.44.bazel b/cargo/remote/BUILD.num-integer-0.1.44.bazel index 8f9a78e..51f2ad6 100644 --- a/cargo/remote/BUILD.num-integer-0.1.44.bazel +++ b/cargo/remote/BUILD.num-integer-0.1.44.bazel @@ -42,8 +42,6 @@ cargo_build_script( build_script_env = { }, crate_features = [ - "i128", - "std", ], crate_root = "build.rs", data = glob(["**"]), @@ -72,8 +70,6 @@ rust_library( name = "num_integer", srcs = glob(["**/*.rs"]), crate_features = [ - "i128", - "std", ], crate_root = "src/lib.rs", crate_type = "lib", diff --git a/cargo/remote/BUILD.num-iter-0.1.42.bazel b/cargo/remote/BUILD.num-iter-0.1.42.bazel deleted file mode 100644 index ecf8946..0000000 --- a/cargo/remote/BUILD.num-iter-0.1.42.bazel +++ /dev/null @@ -1,90 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets -# buildifier: disable=out-of-order-load -# buildifier: disable=load-on-top -load( - "@rules_rust//cargo:cargo_build_script.bzl", - "cargo_build_script", -) - -cargo_build_script( - name = "num_iter_build_script", - srcs = glob(["**/*.rs"]), - build_script_env = { - }, - crate_features = [ - "i128", - "std", - ], - crate_root = "build.rs", - data = glob(["**"]), - edition = "2015", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.1.42", - visibility = ["//visibility:private"], - deps = [ - "@raze__autocfg__1_0_1//:autocfg", - ], -) - -rust_library( - name = "num_iter", - srcs = glob(["**/*.rs"]), - crate_features = [ - "i128", - "std", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2015", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.1.42", - # buildifier: leave-alone - deps = [ - ":num_iter_build_script", - "@raze__num_integer__0_1_44//:num_integer", - "@raze__num_traits__0_2_14//:num_traits", - ], -) diff --git a/cargo/remote/BUILD.num-rational-0.4.0.bazel b/cargo/remote/BUILD.num-rational-0.4.0.bazel deleted file mode 100644 index 6d9ef28..0000000 --- a/cargo/remote/BUILD.num-rational-0.4.0.bazel +++ /dev/null @@ -1,93 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets -# buildifier: disable=out-of-order-load -# buildifier: disable=load-on-top -load( - "@rules_rust//cargo:cargo_build_script.bzl", - "cargo_build_script", -) - -cargo_build_script( - name = "num_rational_build_script", - srcs = glob(["**/*.rs"]), - build_script_env = { - }, - crate_features = [ - "num-bigint", - "num-bigint-std", - "std", - ], - crate_root = "build.rs", - data = glob(["**"]), - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.0", - visibility = ["//visibility:private"], - deps = [ - "@raze__autocfg__1_0_1//:autocfg", - ], -) - -rust_library( - name = "num_rational", - srcs = glob(["**/*.rs"]), - crate_features = [ - "num-bigint", - "num-bigint-std", - "std", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.4.0", - # buildifier: leave-alone - deps = [ - ":num_rational_build_script", - "@raze__num_bigint__0_4_2//:num_bigint", - "@raze__num_integer__0_1_44//:num_integer", - "@raze__num_traits__0_2_14//:num_traits", - ], -) diff --git a/cargo/remote/BUILD.num-traits-0.2.14.bazel b/cargo/remote/BUILD.num-traits-0.2.14.bazel index dc9a697..1e6e653 100644 --- a/cargo/remote/BUILD.num-traits-0.2.14.bazel +++ b/cargo/remote/BUILD.num-traits-0.2.14.bazel @@ -43,7 +43,6 @@ cargo_build_script( }, crate_features = [ "default", - "i128", "std", ], crate_root = "build.rs", @@ -68,7 +67,6 @@ rust_library( srcs = glob(["**/*.rs"]), crate_features = [ "default", - "i128", "std", ], crate_root = "src/lib.rs", diff --git a/cargo/remote/BUILD.ordered-float-2.8.0.bazel b/cargo/remote/BUILD.ordered-float-2.8.0.bazel new file mode 100644 index 0000000..b64a3ae --- /dev/null +++ b/cargo/remote/BUILD.ordered-float-2.8.0.bazel @@ -0,0 +1,58 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "ordered_float", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "2.8.0", + # buildifier: leave-alone + deps = [ + "@raze__num_traits__0_2_14//:num_traits", + ], +) + +# Unsupported target "test" with type "test" omitted diff --git a/cargo/remote/BUILD.serde-value-0.7.0.bazel b/cargo/remote/BUILD.serde-value-0.7.0.bazel new file mode 100644 index 0000000..675a2d1 --- /dev/null +++ b/cargo/remote/BUILD.serde-value-0.7.0.bazel @@ -0,0 +1,55 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "serde_value", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.7.0", + # buildifier: leave-alone + deps = [ + "@raze__ordered_float__2_8_0//:ordered_float", + "@raze__serde__1_0_130//:serde", + ], +) diff --git a/cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel b/cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel new file mode 100644 index 0000000..d8df4a4 --- /dev/null +++ b/cargo/remote/BUILD.tokio-tungstenite-0.14.0.bazel @@ -0,0 +1,85 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "autobahn-client" with type "example" omitted + +# Unsupported target "autobahn-server" with type "example" omitted + +# Unsupported target "client" with type "example" omitted + +# Unsupported target "echo-server" with type "example" omitted + +# Unsupported target "interval-server" with type "example" omitted + +# Unsupported target "server" with type "example" omitted + +rust_library( + name = "tokio_tungstenite", + srcs = glob(["**/*.rs"]), + crate_features = [ + "connect", + "rustls", + "rustls-tls", + "stream", + "tokio-rustls", + "webpki", + "webpki-roots", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.14.0", + # buildifier: leave-alone + deps = [ + "@raze__futures_util__0_3_17//:futures_util", + "@raze__log__0_4_14//:log", + "@raze__pin_project__1_0_8//:pin_project", + "@raze__rustls__0_19_1//:rustls", + "@raze__tokio__1_12_0//:tokio", + "@raze__tokio_rustls__0_22_0//:tokio_rustls", + "@raze__tungstenite__0_13_0//:tungstenite", + "@raze__webpki__0_21_4//:webpki", + "@raze__webpki_roots__0_21_1//:webpki_roots", + ], +) + +# Unsupported target "communication" with type "test" omitted + +# Unsupported target "handshakes" with type "test" omitted diff --git a/cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel b/cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel deleted file mode 100644 index d292afc..0000000 --- a/cargo/remote/BUILD.tokio-tungstenite-0.15.0.bazel +++ /dev/null @@ -1,86 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT" -]) - -# Generated Targets - -# Unsupported target "autobahn-client" with type "example" omitted - -# Unsupported target "autobahn-server" with type "example" omitted - -# Unsupported target "client" with type "example" omitted - -# Unsupported target "echo-server" with type "example" omitted - -# Unsupported target "interval-server" with type "example" omitted - -# Unsupported target "server" with type "example" omitted - -rust_library( - name = "tokio_tungstenite", - srcs = glob(["**/*.rs"]), - crate_features = [ - "connect", - "default", - "rustls", - "rustls-tls", - "stream", - "tokio-rustls", - "webpki", - "webpki-roots", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.15.0", - # buildifier: leave-alone - deps = [ - "@raze__futures_util__0_3_17//:futures_util", - "@raze__log__0_4_14//:log", - "@raze__pin_project__1_0_8//:pin_project", - "@raze__rustls__0_19_1//:rustls", - "@raze__tokio__1_12_0//:tokio", - "@raze__tokio_rustls__0_22_0//:tokio_rustls", - "@raze__tungstenite__0_14_0//:tungstenite", - "@raze__webpki__0_21_4//:webpki", - "@raze__webpki_roots__0_21_1//:webpki_roots", - ], -) - -# Unsupported target "communication" with type "test" omitted - -# Unsupported target "handshakes" with type "test" omitted diff --git a/cargo/remote/BUILD.tracing-0.1.29.bazel b/cargo/remote/BUILD.tracing-0.1.29.bazel index e0ccc93..2573d6c 100644 --- a/cargo/remote/BUILD.tracing-0.1.29.bazel +++ b/cargo/remote/BUILD.tracing-0.1.29.bazel @@ -40,12 +40,17 @@ rust_library( aliases = { }, crate_features = [ + "attributes", "std", + "tracing-attributes", ], crate_root = "src/lib.rs", crate_type = "lib", data = [], edition = "2018", + proc_macro_deps = [ + "@raze__tracing_attributes__0_1_18//:tracing_attributes", + ], rustc_flags = [ "--cap-lints=allow", ], diff --git a/cargo/remote/BUILD.tracing-attributes-0.1.18.bazel b/cargo/remote/BUILD.tracing-attributes-0.1.18.bazel new file mode 100644 index 0000000..efdecca --- /dev/null +++ b/cargo/remote/BUILD.tracing-attributes-0.1.18.bazel @@ -0,0 +1,74 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "tracing_attributes", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "proc-macro", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.1.18", + # buildifier: leave-alone + deps = [ + "@raze__proc_macro2__1_0_30//:proc_macro2", + "@raze__quote__1_0_10//:quote", + "@raze__syn__1_0_80//:syn", + ], +) + +# Unsupported target "async_fn" with type "test" omitted + +# Unsupported target "destructuring" with type "test" omitted + +# Unsupported target "err" with type "test" omitted + +# Unsupported target "fields" with type "test" omitted + +# Unsupported target "instrument" with type "test" omitted + +# Unsupported target "levels" with type "test" omitted + +# Unsupported target "names" with type "test" omitted + +# Unsupported target "support" with type "test" omitted + +# Unsupported target "targets" with type "test" omitted diff --git a/cargo/remote/BUILD.tungstenite-0.13.0.bazel b/cargo/remote/BUILD.tungstenite-0.13.0.bazel new file mode 100644 index 0000000..9292f39 --- /dev/null +++ b/cargo/remote/BUILD.tungstenite-0.13.0.bazel @@ -0,0 +1,90 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +# Unsupported target "autobahn-client" with type "example" omitted + +# Unsupported target "autobahn-server" with type "example" omitted + +# Unsupported target "callback-error" with type "example" omitted + +# Unsupported target "client" with type "example" omitted + +# Unsupported target "server" with type "example" omitted + +# Unsupported target "srv_accept_unmasked_frames" with type "example" omitted + +rust_library( + name = "tungstenite", + srcs = glob(["**/*.rs"]), + crate_features = [ + "rustls", + "rustls-tls", + "webpki", + "webpki-roots", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.13.0", + # buildifier: leave-alone + deps = [ + "@raze__base64__0_13_0//:base64", + "@raze__byteorder__1_4_3//:byteorder", + "@raze__bytes__1_1_0//:bytes", + "@raze__http__0_2_5//:http", + "@raze__httparse__1_5_1//:httparse", + "@raze__input_buffer__0_4_0//:input_buffer", + "@raze__log__0_4_14//:log", + "@raze__rand__0_8_4//:rand", + "@raze__rustls__0_19_1//:rustls", + "@raze__sha_1__0_9_8//:sha_1", + "@raze__thiserror__1_0_30//:thiserror", + "@raze__url__2_2_2//:url", + "@raze__utf_8__0_7_6//:utf_8", + "@raze__webpki__0_21_4//:webpki", + "@raze__webpki_roots__0_21_1//:webpki_roots", + ], +) + +# Unsupported target "connection_reset" with type "test" omitted + +# Unsupported target "no_send_after_close" with type "test" omitted + +# Unsupported target "receive_after_init_close" with type "test" omitted diff --git a/cargo/remote/BUILD.tungstenite-0.14.0.bazel b/cargo/remote/BUILD.tungstenite-0.14.0.bazel deleted file mode 100644 index 55a7335..0000000 --- a/cargo/remote/BUILD.tungstenite-0.14.0.bazel +++ /dev/null @@ -1,91 +0,0 @@ -""" -@generated -cargo-raze crate build file. - -DO NOT EDIT! Replaced on runs of cargo-raze -""" - -# buildifier: disable=load -load("@bazel_skylib//lib:selects.bzl", "selects") - -# buildifier: disable=load -load( - "@rules_rust//rust:rust.bzl", - "rust_binary", - "rust_library", - "rust_test", -) - -package(default_visibility = [ - # Public for visibility by "@raze__crate__version//" targets. - # - # Prefer access through "//cargo", which limits external - # visibility to explicit Cargo.toml dependencies. - "//visibility:public", -]) - -licenses([ - "notice", # MIT from expression "MIT OR Apache-2.0" -]) - -# Generated Targets - -# Unsupported target "buffer" with type "bench" omitted - -# Unsupported target "autobahn-client" with type "example" omitted - -# Unsupported target "autobahn-server" with type "example" omitted - -# Unsupported target "callback-error" with type "example" omitted - -# Unsupported target "client" with type "example" omitted - -# Unsupported target "server" with type "example" omitted - -# Unsupported target "srv_accept_unmasked_frames" with type "example" omitted - -rust_library( - name = "tungstenite", - srcs = glob(["**/*.rs"]), - crate_features = [ - "rustls", - "rustls-native-certs", - "rustls-tls", - "webpki", - ], - crate_root = "src/lib.rs", - crate_type = "lib", - data = [], - edition = "2018", - rustc_flags = [ - "--cap-lints=allow", - ], - tags = [ - "cargo-raze", - "manual", - ], - version = "0.14.0", - # buildifier: leave-alone - deps = [ - "@raze__base64__0_13_0//:base64", - "@raze__byteorder__1_4_3//:byteorder", - "@raze__bytes__1_1_0//:bytes", - "@raze__http__0_2_5//:http", - "@raze__httparse__1_5_1//:httparse", - "@raze__log__0_4_14//:log", - "@raze__rand__0_8_4//:rand", - "@raze__rustls__0_19_1//:rustls", - "@raze__rustls_native_certs__0_5_0//:rustls_native_certs", - "@raze__sha_1__0_9_8//:sha_1", - "@raze__thiserror__1_0_30//:thiserror", - "@raze__url__2_2_2//:url", - "@raze__utf_8__0_7_6//:utf_8", - "@raze__webpki__0_21_4//:webpki", - ], -) - -# Unsupported target "connection_reset" with type "test" omitted - -# Unsupported target "no_send_after_close" with type "test" omitted - -# Unsupported target "receive_after_init_close" with type "test" omitted diff --git a/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel b/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel new file mode 100644 index 0000000..aace272 --- /dev/null +++ b/cargo/remote/BUILD.twilight-gateway-0.6.5.bazel @@ -0,0 +1,72 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # ISC from expression "ISC" +]) + +# Generated Targets + +rust_library( + name = "twilight_gateway", + srcs = glob(["**/*.rs"]), + crate_features = [ + "compression", + "default", + "flate2", + "rustls", + "rustls-native-roots", + "tracing", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.6.5", + # buildifier: leave-alone + deps = [ + "@raze__bitflags__1_3_2//:bitflags", + "@raze__flate2__1_0_22//:flate2", + "@raze__futures_util__0_3_17//:futures_util", + "@raze__once_cell__1_8_0//:once_cell", + "@raze__serde__1_0_130//:serde", + "@raze__serde_json__1_0_68//:serde_json", + "@raze__tokio__1_12_0//:tokio", + "@raze__tokio_tungstenite__0_14_0//:tokio_tungstenite", + "@raze__tracing__0_1_29//:tracing", + "@raze__twilight_gateway_queue__0_6_0//:twilight_gateway_queue", + "@raze__twilight_http__0_6_6//:twilight_http", + "@raze__twilight_model__0_6_5//:twilight_model", + "@raze__url__2_2_2//:url", + ], +) diff --git a/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel b/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel new file mode 100644 index 0000000..7840285 --- /dev/null +++ b/cargo/remote/BUILD.twilight-gateway-queue-0.6.0.bazel @@ -0,0 +1,57 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # ISC from expression "ISC" +]) + +# Generated Targets + +rust_library( + name = "twilight_gateway_queue", + srcs = glob(["**/*.rs"]), + crate_features = [ + "rustls-native-roots", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.6.0", + # buildifier: leave-alone + deps = [ + "@raze__tokio__1_12_0//:tokio", + "@raze__tracing__0_1_29//:tracing", + "@raze__twilight_http__0_6_6//:twilight_http", + ], +) diff --git a/cargo/remote/BUILD.twilight-http-0.6.6.bazel b/cargo/remote/BUILD.twilight-http-0.6.6.bazel new file mode 100644 index 0000000..05391e8 --- /dev/null +++ b/cargo/remote/BUILD.twilight-http-0.6.6.bazel @@ -0,0 +1,65 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # ISC from expression "ISC" +]) + +# Generated Targets + +# Unsupported target "application_command_permissions" with type "bench" omitted + +rust_library( + name = "twilight_http", + srcs = glob(["**/*.rs"]), + crate_features = [ + "hyper-rustls", + "rustls-native-roots", + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.6.6", + # buildifier: leave-alone + deps = [ + "@raze__hyper__0_14_13//:hyper", + "@raze__hyper_rustls__0_22_1//:hyper_rustls", + "@raze__percent_encoding__2_1_0//:percent_encoding", + "@raze__rand__0_8_4//:rand", + "@raze__serde__1_0_130//:serde", + "@raze__serde_json__1_0_68//:serde_json", + "@raze__tokio__1_12_0//:tokio", + "@raze__twilight_model__0_6_5//:twilight_model", + ], +) diff --git a/cargo/remote/BUILD.twilight-model-0.6.5.bazel b/cargo/remote/BUILD.twilight-model-0.6.5.bazel new file mode 100644 index 0000000..dbadd52 --- /dev/null +++ b/cargo/remote/BUILD.twilight-model-0.6.5.bazel @@ -0,0 +1,62 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:rust.bzl", + "rust_binary", + "rust_library", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # ISC from expression "ISC" +]) + +# Generated Targets + +# Unsupported target "deserialization" with type "bench" omitted + +rust_library( + name = "twilight_model", + srcs = glob(["**/*.rs"]), + crate_features = [ + ], + crate_root = "src/lib.rs", + crate_type = "lib", + data = [], + edition = "2018", + proc_macro_deps = [ + "@raze__serde_repr__0_1_7//:serde_repr", + ], + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.6.5", + # buildifier: leave-alone + deps = [ + "@raze__bitflags__1_3_2//:bitflags", + "@raze__serde__1_0_130//:serde", + "@raze__serde_value__0_7_0//:serde_value", + "@raze__tracing__0_1_29//:tracing", + ], +) diff --git a/common/rust/Cargo.toml b/common/rust/Cargo.toml index 234f1b1..07f9dd3 100644 --- a/common/rust/Cargo.toml +++ b/common/rust/Cargo.toml @@ -15,6 +15,8 @@ enumflags2 = { version = "0.7.1", features = ["serde"] } prometheus = { version = "0.12.0", features = ["process"] } nats = "0.15.2" testcontainers = "0.12.0" +twilight-model = { version = "0.6" } +serde_json = { version = "1.0" } [dependencies.redis] version = "*" diff --git a/common/rust/cargo/BUILD.bazel b/common/rust/cargo/BUILD.bazel index f3778e2..387da21 100644 --- a/common/rust/cargo/BUILD.bazel +++ b/common/rust/cargo/BUILD.bazel @@ -93,6 +93,15 @@ alias( ], ) +alias( + name = "serde_json", + actual = "@raze__serde_json__1_0_68//:serde_json", + tags = [ + "cargo-raze", + "manual", + ], +) + alias( name = "serde_repr", actual = "@raze__serde_repr__0_1_7//:serde_repr", @@ -119,3 +128,12 @@ alias( "manual", ], ) + +alias( + name = "twilight_model", + actual = "@raze__twilight_model__0_6_5//:twilight_model", + tags = [ + "cargo-raze", + "manual", + ], +) diff --git a/common/rust/src/discord_models/application.rs b/common/rust/src/discord_models/application.rs deleted file mode 100644 index 65707d2..0000000 --- a/common/rust/src/discord_models/application.rs +++ /dev/null @@ -1,38 +0,0 @@ -use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; - -use super::{teams::Team, user::User}; - -#[bitflags] -#[repr(u64)] -#[derive(Debug, Clone, Copy)] -pub enum ApplicationFlags { - GatewayPresence = 1 << 12, - GatewayPresenceLimit = 1 << 13, - GatewayGuildMembers = 1 << 14, - GatewayGuildMembersLimited = 1 << 15, - VerificationPendingGuildLimit = 1 << 16, - Embedded = 1 << 17, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Application { - pub id: String, - pub name: String, - pub icon: Option, - pub description: String, - pub rpc_origins: Option>, - pub bot_public: bool, - pub bot_require_code_grant: bool, - pub terms_of_service_url: Option, - pub privacy_policy_url: Option, - pub owner: Option, - pub summary: String, - pub verify_key: String, - pub team: Option, - pub guild_id: Option, - pub primary_sku_id: Option, - pub slug: Option, - pub cover_image: Option, - pub flags: Option>, -} diff --git a/common/rust/src/discord_models/audit_log.rs b/common/rust/src/discord_models/audit_log.rs deleted file mode 100644 index f223a2f..0000000 --- a/common/rust/src/discord_models/audit_log.rs +++ /dev/null @@ -1,214 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::discord_models::channel::Channel; - -use super::{guild::Integration, user::User, webhook::Webhook}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum AuditLogEvents { - GuildUpdate = 1, - ChannelCreate = 10, - ChannelUpdate = 11, - ChannelDelete = 12, - ChannelOverwriteCreate = 13, - ChannelOverwriteUpdate = 14, - ChannelOverwriteDelete = 15, - MemberKick = 20, - MemberPrune = 21, - MemberBanAdd = 22, - MemberBanRemove = 23, - MemberUpdate = 24, - MemberRoleUpdate = 25, - MemberMove = 26, - MemberDisconnect = 27, - BotAdd = 28, - RoleCreate = 30, - RoleUpdate = 31, - RoleDelete = 32, - InviteCreate = 40, - InviteUpdate = 41, - InviteDelete = 42, - WebhookCreate = 50, - WebhookUpdate = 51, - WebhookDelete = 52, - EmojiCreate = 60, - EmojiUpdate = 61, - EmojiDelete = 62, - MessageDelete = 72, - MessageBulkDelete = 73, - MessagePin = 74, - MessageUnpin = 75, - IntegrationCreate = 80, - IntegrationUpdate = 81, - IntegrationDelete = 82, - StageInstanceCreate = 83, - StageInstanceUpdate = 84, - StageInstanceDelete = 85, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum OptionalAuditEntryInfoType { - #[serde(rename = "0")] - Role, - #[serde(rename = "1")] - Member, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct OptionalAuditEntryInfo { - pub delete_member_days: Option, - pub members_removed: Option, - pub channel_id: Option, - pub message_id: Option, - pub count: Option, - pub id: Option, - #[serde(rename = "type")] - pub type_: Option>, - pub role_name: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum AuditLogChangeKey { - #[serde(rename = "name")] - Name, - #[serde(rename = "description")] - Description, - #[serde(rename = "icon_hash")] - IconHash, - #[serde(rename = "splash_hash")] - SplashHash, - #[serde(rename = "discovery_splash_hash")] - DiscoverySplashHash, - #[serde(rename = "banner_hash")] - BannerHash, - #[serde(rename = "owner_id")] - OwnerId, - #[serde(rename = "region")] - Region, - #[serde(rename = "preferred_locale")] - PreferredLocale, - #[serde(rename = "afk_channel_id")] - AfkChannelId, - #[serde(rename = "afk_timeout")] - AfkTimeout, - #[serde(rename = "rules_channel_id")] - RulesChannelId, - #[serde(rename = "public_updates_channel_id")] - PublicUpdatesChannelId, - #[serde(rename = "mfa_level")] - MfaLevel, - #[serde(rename = "verification_level")] - VerificationLevel, - #[serde(rename = "explicit_content_filter")] - ExplicitContentFilter, - #[serde(rename = "default_message_notifications")] - DefaultMessageNotifications, - #[serde(rename = "vanity_url_code")] - VanityUrlCode, - #[serde(rename = "$add")] - Add, - #[serde(rename = "$remove")] - Remove, - #[serde(rename = "prune_delete_days")] - PruneDeleteDays, - #[serde(rename = "widget_enabled")] - WidgetEnabled, - #[serde(rename = "widget_channel_id")] - WidgetChannelId, - #[serde(rename = "system_channel_id")] - SystemChannelId, - #[serde(rename = "position")] - Position, - #[serde(rename = "topic")] - Topic, - #[serde(rename = "bitrate")] - Bitrate, - #[serde(rename = "permission_overwrites")] - PermissionOverwrites, - #[serde(rename = "nsfw")] - Nsfw, - #[serde(rename = "application_id")] - ApplicationId, - #[serde(rename = "rate_limit_per_user")] - RateLimitPerUser, - #[serde(rename = "permissions")] - Permissions, - #[serde(rename = "color")] - Color, - #[serde(rename = "hoist")] - Hoist, - #[serde(rename = "mentionable")] - Mentionable, - #[serde(rename = "allow")] - Allow, - #[serde(rename = "deny")] - Deny, - #[serde(rename = "code")] - Code, - #[serde(rename = "channel_id")] - ChannelId, - #[serde(rename = "inviter_id")] - InviterId, - #[serde(rename = "max_uses")] - MaxUses, - #[serde(rename = "uses")] - Uses, - #[serde(rename = "max_age")] - MaxAge, - #[serde(rename = "temporary")] - Temporary, - #[serde(rename = "deaf")] - Deaf, - #[serde(rename = "mute")] - Mute, - #[serde(rename = "nick")] - Nick, - #[serde(rename = "avatar_hash")] - AvatarHash, - #[serde(rename = "id")] - Id, - #[serde(rename = "type")] - Type, - #[serde(rename = "enable_emoticons")] - EnableEmoticons, - #[serde(rename = "expire_behavior")] - ExpireBehavior, - #[serde(rename = "expire_grace_period")] - ExpireGracePeriod, - #[serde(rename = "user_limit")] - UserLimit, - #[serde(rename = "privacy_level")] - PrivacyLevel, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct AuditLogChange { - pub new_value: Option, - pub old_value: Option, - pub key: AuditLogChangeKey, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct AuditLogEntry { - pub target_id: Option, - pub changes: Option>, - pub user_id: Option, - pub id: String, - pub action_type: AuditLogEvents, - pub options: Option, - pub reason: Option, -} - -pub enum NewAuditLogEntry { - -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct AuditLog { - pub webhooks: Vec, - pub users: Vec, - pub threads: Vec, - pub audit_log_entries: Vec, - pub integrations: Vec, -} diff --git a/common/rust/src/discord_models/channel.rs b/common/rust/src/discord_models/channel.rs deleted file mode 100644 index ef31aa1..0000000 --- a/common/rust/src/discord_models/channel.rs +++ /dev/null @@ -1,341 +0,0 @@ -use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::{ - application::Application, emoji::Emoji, guild::GuildMember, message_components::Component, - slash_commands::MessageInteraction, user::User, -}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ChannelTypes { - GuildText = 0, - Dm = 1, - GuildVoice = 2, - GroupDm = 3, - GuildCategory = 4, - GuildNews = 5, - GuildStore = 6, - GuildNewsThread = 10, - GuildPublicThread = 11, - GuildPrivateThread = 12, - GuildStageVoice = 13, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum VideoQualityModes { - Auto = 1, - Full = 2, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum OverwriteTypes { - Role = 0, - Member = 1, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Overwrite { - pub id: String, - #[serde(rename = "type")] - pub type_: OverwriteTypes, - pub allow: String, - pub deny: String, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ThreadMetadata { - pub archived: bool, - pub auto_archive_duration: i64, - pub archive_timestamp: String, - pub locked: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ThreadMember { - pub id: Option, - pub user_id: Option, - pub join_timestamp: String, - pub flags: i64, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Channel { - pub id: String, - #[serde(rename = "type")] - pub type_: ChannelTypes, - pub guild_id: Option, - pub position: Option, - pub permission_overwrites: Option>, - pub name: Option, - pub topic: Option, - pub nsfw: Option, - pub last_message_id: Option, - pub bitrate: Option, - pub user_limit: Option, - pub rate_limit_per_user: Option, - pub recipients: Option>, - pub icon: Option, - pub owner_id: Option, - pub application_id: Option, - pub parent_id: Option, - pub last_pin_timestamp: Option, - pub rtc_region: Option, - pub video_quality_mode: Option, - pub message_count: Option, - pub member_count: Option, - pub thread_metadata: Option, - pub member: Option, - pub default_auto_archive_duration: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Attachment { - pub id: String, - pub filename: String, - pub content_type: String, - pub size: i64, - pub url: String, - pub proxy_url: String, - pub height: Option, - pub width: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ChannelMention { - pub id: String, - pub guild_id: String, - #[serde(rename = "type")] - pub type_: ChannelTypes, - pub name: String, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum EmbedTypes { - #[serde(rename = "rich")] - Rich, - #[serde(rename = "image")] - Image, - #[serde(rename = "video")] - Video, - #[serde(rename = "gifv")] - Gifv, - #[serde(rename = "article")] - Article, - #[serde(rename = "link")] - Link, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedThumbnail { - pub url: Option, - pub proxy_url: Option, - pub height: Option, - pub width: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedVideo { - pub url: Option, - pub proxy_url: Option, - pub height: Option, - pub width: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedImage { - pub url: Option, - pub proxy_url: Option, - pub height: Option, - pub width: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedProvider { - pub name: Option, - pub url: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedAuthor { - pub name: Option, - pub url: Option, - pub icon_url: Option, - pub proxy_icon_url: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedFooter { - pub text: String, - pub icon_url: Option, - pub proxy_icon_url: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct EmbedField { - pub name: String, - pub value: String, - pub inline: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Embed { - pub title: Option, - #[serde(rename = "type")] - pub type_: Option, - pub description: Option, - pub url: Option, - pub timestamp: Option, - pub color: Option, - pub footer: Option, - pub image: Option, - pub thumbnail: Option, - pub video: Option, - pub provider: Option, - pub author: Option, - pub fields: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Reaction { - pub count: i64, - pub me: bool, - pub emoji: Emoji, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum MessageTypes { - Default = 0, - RecipientAdd = 1, - RecipientRemove = 2, - Call = 3, - ChannelNameChange = 4, - ChannelIconChange = 5, - ChannelPinnedMessage = 6, - GuildMemberJoin = 7, - UserPremiumGuildSubscription = 8, - UserPremiumGuildSubscriptionTier1 = 9, - UserPremiumGuildSubscriptionTier2 = 10, - UserPremiumGuildSubscriptionTier3 = 11, - ChannelFollowAdd = 12, - GuildDiscoveryDisqualified = 14, - GuildDiscoveryRequalified = 15, - GuildDiscoveryGracePeriodInitialWarning = 16, - GuildDiscoveryGracePeriodFinalWarning = 17, - ThreadCreated = 18, - Reply = 19, - ApplicationCommand = 20, - ThreadStarterMessage = 21, - GuildInviteReminder = 22, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum MessageActivityTypes { - Join = 1, - Spectate = 2, - Listen = 3, - JoinRequest = 5, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct MessageActivity { - #[serde(rename = "type")] - pub type_: MessageActivityTypes, - pub party_id: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct MessageReference { - pub message_id: Option, - pub channel_id: Option, - pub guild_id: Option, - pub fail_if_not_exists: Option, -} - -#[bitflags] -#[repr(u64)] -#[derive(Debug, Clone, Copy)] -pub enum MessageFlags { - Crossposted = 1 << 0, - IsCrosspost = 1 << 1, - SuppressEmbeds = 1 << 2, - SourceMessageDeleted = 1 << 3, - Urgent = 1 << 4, - HasThread = 1 << 5, - Ephemeral = 1 << 6, - Loading = 1 << 7, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum MessageStickerFormatTypes { - Png = 1, - Apng = 2, - Lottie = 3, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct MessageStickerItem { - pub id: String, - pub name: String, - pub format_type: MessageStickerFormatTypes, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct MessageSticker { - pub id: String, - pub pack_id: Option, - pub name: String, - pub description: String, - pub tags: String, - // deprecated - // pub asset: String, - pub format_type: MessageStickerFormatTypes, - pub available: Option, - pub guild_id: Option, - pub user: Option, - pub sort_value: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Message { - pub id: String, - pub channel_id: String, - pub guild_id: Option, - pub author: User, - pub member: Option, - pub content: String, - pub timestamp: String, - pub edited_timestamp: String, - pub tts: bool, - pub mention_everyone: bool, - pub mentions: Vec, // todo: It is a Vector of User objects, with an additional partial member field (GuildMember) - pub mentions_roles: Vec, - pub mention_channels: Option>, - pub attachments: Vec, - pub embeds: Vec, - pub reactions: Option>, - /// ! Can be a String or an int ! - pub nonce: Option, - pub pinned: bool, - pub webhook_id: Option, - #[serde(rename = "type")] - pub type_: MessageTypes, - pub activity: Option, - pub application: Option, - pub application_id: Option, - pub message_reference: Option, - pub flags: Option>, - pub referenced_message: Option>, - pub interaction: Option, - pub thread: Option, - pub components: Option, - pub sticker_items: Option>, - // deprecated - // pub stickers: Option>, -} diff --git a/common/rust/src/discord_models/emoji.rs b/common/rust/src/discord_models/emoji.rs deleted file mode 100644 index eec02e7..0000000 --- a/common/rust/src/discord_models/emoji.rs +++ /dev/null @@ -1,15 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use super::user::User; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Emoji { - pub id: Option, - pub name: Option, - pub roles: Vec, - pub user: Option, - pub require_colons: Option, - pub managed: Option, - pub animated: Option, - pub available: Option, -} diff --git a/common/rust/src/discord_models/gateway.rs b/common/rust/src/discord_models/gateway.rs deleted file mode 100644 index a886d99..0000000 --- a/common/rust/src/discord_models/gateway.rs +++ /dev/null @@ -1,124 +0,0 @@ -use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::user::User; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub enum PresenceUpdateStatus { - #[serde(rename = "online")] - Online, - #[serde(rename = "idle")] - Idle, - #[serde(rename = "dnd")] - Dnd, - #[serde(rename = "offline")] - Offline, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ClientStatus { - pub desktop: Option, - pub mobile: Option, - pub web: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct PresenceUpdate { - pub user: User, - pub guild_id: String, - pub status: PresenceUpdateStatus, - pub activities: Vec, - pub client_status: ClientStatus, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ActivityTypes { - Game = 0, - Streaming = 1, - Listening = 2, - Watching = 3, - Custom = 4, - Competing = 5, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivityTimestamps { - pub start: Option, - pub end: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivityEmoji { - pub name: String, - pub id: Option, - pub animated: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivityParty { - pub id: Option, - /// [current_size, max_size] - pub size: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivityAssets { - pub large_image: Option, - pub large_text: Option, - pub small_image: Option, - pub small_text: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivitySecrets { - pub join: Option, - pub spectate: Option, - #[serde(rename = "match")] - pub match_: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ActivityButtons { - pub label: String, - pub url: String, -} - -#[bitflags] -#[repr(u64)] -#[derive(Debug, Clone, Copy)] -pub enum ActivityFlags { - Instance = 1 << 0, - Join = 1 << 1, - Spectate = 1 << 2, - JoinRequest = 1 << 3, - Sync = 1 << 4, - Play = 1 << 5, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Activity { - pub name: String, - #[serde(rename = "type")] - pub type_: ActivityTypes, - pub url: Option, - pub created_at: String, - pub timestamps: Option, - pub application_id: Option, - pub details: Option, - pub state: Option, - pub emoji: Option, - pub party: Option, - pub assets: Option, - pub secrets: Option, - pub instance: Option, - pub flags: Option>, - pub buttons: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(tag = "type")] -pub enum NewActivity { - -} \ No newline at end of file diff --git a/common/rust/src/discord_models/guild.rs b/common/rust/src/discord_models/guild.rs deleted file mode 100644 index 85da5b2..0000000 --- a/common/rust/src/discord_models/guild.rs +++ /dev/null @@ -1,255 +0,0 @@ -use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::{ - channel::Channel, emoji::Emoji, gateway::PresenceUpdate, permissions::Role, - stage_instance::StageInstance, user::User, voice::VoiceState, -}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum IntegrationExpireBehavior { - RemoveRole = 0, - Kick = 1, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct IntegrationAccount { - pub id: String, - pub name: String, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct IntegrationApplication { - pub id: String, - pub name: String, - pub icon: Option, - pub description: String, - pub summary: Option, - pub bot: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Integration { - pub id: String, - pub name: String, - #[serde(rename = "type")] - pub type_: String, - pub enabled: bool, - pub syncing: Option, - pub role_id: Option, - pub enable_emoticons: Option, - pub expire_behavior: Option, - pub expire_grace_period: Option, - pub user: Option, - pub account: IntegrationAccount, - pub synced_at: Option, - pub subscriber_count: Option, - pub revoked: Option, - pub application: Option, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum VerificationLevel { - None = 0, - Low = 1, - Medium = 2, - High = 3, - VeryHigh = 4, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum PremiumTier { - None = 0, - Tier1 = 1, - Tier2 = 2, - Tier3 = 3, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ExplicitContentFilter { - Disabled = 0, - MembersWithoutRoles = 1, - AllMembers = 2, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum MfaLevel { - None = 0, - Elevated = 1, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum DefaultMessageNotificationLevel { - AllMessages = 0, - OnlyMentions = 1, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum GuildNsfwLevel { - Default = 0, - Explicit = 1, - Safe = 2, - AgeRestricted = 3, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum GuildFeatures { - #[serde(rename = "ANIMATED_ICON")] - AnimatedIcon, - #[serde(rename = "BANNER")] - Banner, - #[serde(rename = "COMMERCE")] - Commerce, - #[serde(rename = "COMMUNITY")] - Community, - #[serde(rename = "DISCOVERABLE")] - Discoverable, - #[serde(rename = "FEATURABLE")] - Featurable, - #[serde(rename = "INVITE_SPLASH")] - InviteSplash, - #[serde(rename = "MEMBER_VERIFICATION_GATE_ENABLED")] - MemberVerificationGateEnabled, - #[serde(rename = "NEWS")] - News, - #[serde(rename = "PARTNERED")] - Partnered, - #[serde(rename = "PREVIEW_ENABLED")] - PreviewEnabled, - #[serde(rename = "VANITY_URL")] - VanityUrl, - #[serde(rename = "VERIFIED")] - Verified, - #[serde(rename = "VIP_REGIONS")] - VipRegions, - #[serde(rename = "WELCOME_SCREEN_ENABLED")] - WelcomeScreenEnabled, - #[serde(rename = "TICKETED_EVENTS_ENABLED")] - TicketedEventsEnabled, - #[serde(rename = "MONETIZATION_ENABLED")] - MonetizationEnabled, - #[serde(rename = "MORE_STICKERS")] - MoreStickers, - #[serde(rename = "THREE_DAY_THREAD_ARCHIVE")] - ThreeDayThreadArchive, - #[serde(rename = "SEVEN_DAY_THREAD_ARCHIVE")] - SevenDayThreadArchive, - #[serde(rename = "PRIVATE_THREADS")] - PrivateThreads, -} - -#[bitflags] -#[repr(u64)] -#[derive(Debug, Clone, Copy)] -pub enum SystemChannelFlags { - SuppressJoinNotifications = 1 << 0, - SuppressPremiumSubscriptions = 1 << 1, - SuppressGuildReminderNotifications = 1 << 2, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct WelcomeScreenChannel { - pub channel_id: String, - pub description: String, - pub emoji_id: Option, - pub emoji_name: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct WelcomeScreen { - pub description: String, - pub welcome_channels: Vec, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Guild { - pub id: String, - pub name: String, - pub icon: Option, - pub icon_hash: Option, - pub splash: Option, - pub discovery_splash: Option, - pub owner: Option, - pub owner_id: String, - pub permissions: Option, - /// DEPRECATED - pub region: Option, - pub afk_channel_id: Option, - pub afk_timeout: i64, - pub widget_enabled: Option, - pub widget_channel_id: Option, - pub verification_level: VerificationLevel, - pub default_message_notifications: DefaultMessageNotificationLevel, - pub explicit_content_filter: ExplicitContentFilter, - pub roles: Vec, - pub emojis: Vec, - pub features: Vec, - pub mfa_level: MfaLevel, - pub application_id: Option, - pub system_channel_id: Option, - pub system_channel_flags: BitFlags, - pub rules_channel_id: Option, - pub joined_at: Option, - pub large: Option, - pub unavailable: Option, - pub member_count: Option, - pub voice_states: Option>, - pub members: Option>, - pub channels: Option>, - pub threads: Option>, - pub presences: Option>, - pub max_presences: Option, - pub vanity_url_code: Option, - pub description: Option, - pub banner: Option, - pub premium_tier: PremiumTier, - pub premium_subscription_count: i64, - pub preferred_locale: String, - pub public_updates_channel_id: Option, - pub max_video_channel_users: Option, - pub approximate_member_count: Option, - pub welcome_screen: Option, - pub nsfw_level: GuildNsfwLevel, - pub stage_instances: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuildMember { - pub user: Option, - pub nick: Option, - pub roles: Vec, - pub joined_at: String, - pub premium_since: Option, - pub deaf: bool, - pub mute: bool, - pub pending: Option, - pub permissions: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuildPreview { - pub id: String, - pub name: String, - pub icon: Option, - pub splash: Option, - pub discovery_splash: Option, - pub emojis: Vec, - pub features: Vec, - pub approximate_member_count: i64, - pub approximate_presence_count: i64, - pub description: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuildWidget { - pub enabled: bool, - pub channel_id: Option, -} diff --git a/common/rust/src/discord_models/guild_template.rs b/common/rust/src/discord_models/guild_template.rs deleted file mode 100644 index 960631d..0000000 --- a/common/rust/src/discord_models/guild_template.rs +++ /dev/null @@ -1,18 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use super::{guild::Guild, user::User}; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuildTemplate { - pub code: String, - pub name: String, - pub description: Option, - pub usage_count: i64, - pub creator_id: String, - pub creator: User, - pub created_at: String, - pub updated_at: String, - pub source_guild_ild: String, - pub serialized_source_guild: Guild, - pub is_dirty: Option, -} diff --git a/common/rust/src/discord_models/invite.rs b/common/rust/src/discord_models/invite.rs deleted file mode 100644 index 639278c..0000000 --- a/common/rust/src/discord_models/invite.rs +++ /dev/null @@ -1,48 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::{ - application::Application, - channel::Channel, - guild::{Guild, GuildMember}, - user::User, -}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum InviteTargetTypes { - Stream = 1, - EmbeddedApplication = 2, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct InviteStageInstance { - pub members: Vec, - pub participant_count: i64, - pub speaker_count: i64, - pub topic: String, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Invite { - pub code: String, - pub guild: Option, - pub channel: Channel, - pub inviter: Option, - pub target_type: Option, - pub target_user: Option, - pub target_application: Option, - pub approximate_presence_count: Option, - pub approximate_member_count: Option, - pub expires_at: Option, - pub stage_instance: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct InviteMetadata { - pub uses: i64, - pub max_uses: i64, - pub max_age: i64, - pub temporary: bool, - pub created_at: String, -} diff --git a/common/rust/src/discord_models/message_components.rs b/common/rust/src/discord_models/message_components.rs deleted file mode 100644 index f71d7ed..0000000 --- a/common/rust/src/discord_models/message_components.rs +++ /dev/null @@ -1,75 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::emoji::Emoji; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ComponentTypes { - ActionRow = 1, - Button = 2, - SelectMenu = 3, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -/// Global representation of a Component, more detailed are Button (if button) and Select Menu (if select menu) -/// Action Rows are just type: 1, content + components -pub struct Component { - #[serde(rename = "type")] - pub type_: ComponentTypes, - pub custom_id: Option, - pub disabled: Option, - pub style: Option, - pub label: Option, - pub emoji: Option, - pub url: Option, - pub options: Vec, - pub placeholder: Option, - pub min_values: Option, - pub max_values: Option, - pub components: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Button { - #[serde(rename = "type")] - /// it should be `2` - pub type_: ComponentTypes, - pub style: ButtonStyles, - pub label: Option, - pub emoji: Option, - pub custom_id: Option, - pub url: Option, - pub disabled: Option, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ButtonStyles { - Primary = 1, - Secondary = 2, - Success = 3, - Danger = 4, - Link = 5, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct SelectOption { - pub label: String, - pub value: String, - pub description: Option, - pub emoji: Option, - pub default: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct SelectMenu { - /// it should be 3 - pub type_: ComponentTypes, - pub custom_id: String, - pub options: Vec, - pub placeholder: Option, - pub min_values: Option, - pub max_values: Option, - pub disabled: Option, -} diff --git a/common/rust/src/discord_models/mod.rs b/common/rust/src/discord_models/mod.rs deleted file mode 100644 index 8017e2a..0000000 --- a/common/rust/src/discord_models/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub mod application; -pub mod audit_log; -pub mod channel; -pub mod emoji; -pub mod gateway; -pub mod guild; -pub mod guild_template; -pub mod invite; -pub mod message_components; -pub mod permissions; -pub mod slash_commands; -pub mod stage_instance; -pub mod teams; -pub mod user; -pub mod voice; -pub mod webhook; diff --git a/common/rust/src/discord_models/permissions.rs b/common/rust/src/discord_models/permissions.rs deleted file mode 100644 index 76fa34a..0000000 --- a/common/rust/src/discord_models/permissions.rs +++ /dev/null @@ -1,21 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct RoleTags { - pub bot_id: Option, - pub integration_id: Option, - pub premium_subscriber: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Role { - pub id: String, - pub name: String, - pub color: i64, - pub hoist: bool, - pub position: i64, - pub permissions: String, - pub managed: bool, - pub mentionable: bool, - pub tags: Option, -} diff --git a/common/rust/src/discord_models/slash_commands.rs b/common/rust/src/discord_models/slash_commands.rs deleted file mode 100644 index 181a622..0000000 --- a/common/rust/src/discord_models/slash_commands.rs +++ /dev/null @@ -1,104 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::{channel::Message, guild::GuildMember, user::User}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ApplicationCommandOptionType { - SubCommand = 1, - SubCommandGroup = 2, - String = 3, - Integer = 4, - Boolean = 5, - User = 6, - Channel = 7, - Role = 8, - Mentionable = 9, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ApplicationCommandOptionChoice { - pub name: String, - /// todo: Can also be a String!!!! - pub value: i64, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ApplicationCommandOption { - #[serde(rename = "type")] - pub type_: ApplicationCommandOptionType, - pub name: String, - pub description: String, - pub required: Option, - pub choices: Option>, - pub options: Option>, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ApplicationCommand { - pub id: String, - pub application_id: String, - pub guild_id: Option, - pub name: String, - pub description: String, - pub options: Option>, - pub default_permission: Option, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum ApplicationCommandPermissionType { - Role = 1, - User = 2, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct GuildApplicationCommandPermissions { - pub id: String, - pub application_id: String, - pub guild_id: String, - pub permissions: Vec, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct ApplicationCommandPermissions { - pub id: String, - #[serde(rename = "type")] - pub type_: ApplicationCommandPermissionType, - pub permission: bool, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum InteractionRequestType { - Ping = 1, - ApplicationCommand = 2, - MessageComponent = 3, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct MessageInteraction { - pub id: String, - #[serde(rename = "type")] - pub type_: InteractionRequestType, - pub name: String, - pub user: User, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Interaction { - pub id: String, - pub application_id: String, - #[serde(rename = "type")] - pub type_: InteractionRequestType, - /// i am not sure about this one https://canary.discord.com/developers/docs/interactions/slash-commands#interaction-object-application-command-interaction-data - pub data: Option, - pub guild_id: Option, - pub channel_id: Option, - pub member: Option, - pub user: Option, - pub token: String, - pub version: i64, - pub message: Option, -} diff --git a/common/rust/src/discord_models/stage_instance.rs b/common/rust/src/discord_models/stage_instance.rs deleted file mode 100644 index 1eee1c2..0000000 --- a/common/rust/src/discord_models/stage_instance.rs +++ /dev/null @@ -1,19 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum PrivacyLevel { - Public = 1, - GuildOnly = 2, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct StageInstance { - pub id: String, - pub guild_id: String, - pub channel_id: String, - pub topic: String, - pub privacy_level: PrivacyLevel, - pub discoverable_disabled: bool, -} diff --git a/common/rust/src/discord_models/teams.rs b/common/rust/src/discord_models/teams.rs deleted file mode 100644 index 369b3cd..0000000 --- a/common/rust/src/discord_models/teams.rs +++ /dev/null @@ -1,28 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::user::User; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum MembershipState { - Invited = 0, - Accepted = 1, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct TeamMembers { - pub membership_state: MembershipState, - pub permissions: Vec, - pub team_id: String, - pub user: User, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Team { - pub icon: Option, - pub id: String, - pub members: Vec, - pub name: String, - pub owner_user_id: String, -} diff --git a/common/rust/src/discord_models/user.rs b/common/rust/src/discord_models/user.rs deleted file mode 100644 index 36914ce..0000000 --- a/common/rust/src/discord_models/user.rs +++ /dev/null @@ -1,73 +0,0 @@ -use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::guild::Integration; - -#[bitflags] -#[repr(u64)] -#[derive(Debug, Clone, Copy)] -pub enum UserFlags { - // None = 0 << 0, - DiscordEmployee = 1 << 0, - PartneredServerOwner = 1 << 1, - HypesquadEvents = 1 << 2, - BugHunterLevel1 = 1 << 3, - HouseBravery = 1 << 6, - HouseBrilliance = 1 << 7, - HouseBalance = 1 << 8, - EarlySupporter = 1 << 9, - TeamUser = 1 << 10, - BugHunterLevel2 = 1 << 14, - VerifiedBot = 1 << 16, - EarlyVerifiedBotDeveloper = 1 << 17, - DiscordCertifiedModerator = 1 << 18, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum PremiumTypes { - None = 0, - NitroClassic = 1, - Nitro = 2, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -/// Represents a User within Discord -pub struct User { - pub id: String, - pub username: String, - pub discriminator: String, - pub avatar: Option, - pub bot: Option, - pub system: Option, - pub mfa_enabled: Option, - pub locale: Option, - pub verified: Option, - pub email: Option, - pub flags: Option>, - pub premium_type: Option, - pub public_flags: Option>, -} - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum VisibilityTypes { - None = 0, - Everyone = 1, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -/// The connection object that the user has attached. -pub struct Connection { - pub id: String, - pub name: String, - #[serde(rename = "type")] - pub type_: String, - pub revoked: Option, - pub integrations: Option>, - pub verified: bool, - pub friend_sync: bool, - pub show_activity: bool, - pub visibility: VisibilityTypes, -} diff --git a/common/rust/src/discord_models/voice.rs b/common/rust/src/discord_models/voice.rs deleted file mode 100644 index 8263af5..0000000 --- a/common/rust/src/discord_models/voice.rs +++ /dev/null @@ -1,30 +0,0 @@ -use serde::{Deserialize, Serialize}; - -use super::guild::GuildMember; - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct VoiceState { - pub guild_id: Option, - pub channel_id: Option, - pub user_id: String, - pub member: Option, - pub session_id: String, - pub deaf: bool, - pub mute: bool, - pub self_deaf: bool, - pub self_mute: bool, - pub self_stream: Option, - pub self_video: bool, - pub suppress: bool, - pub request_to_speak_timestamp: Option, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct VoiceRegion { - pub id: String, - pub name: String, - pub vip: bool, - pub optimal: bool, - pub deprecated: bool, - pub custom: bool, -} diff --git a/common/rust/src/discord_models/webhook.rs b/common/rust/src/discord_models/webhook.rs deleted file mode 100644 index 4648772..0000000 --- a/common/rust/src/discord_models/webhook.rs +++ /dev/null @@ -1,29 +0,0 @@ -use serde::{Deserialize, Serialize}; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -use super::{channel::Channel, guild::Guild, user::User}; - -#[derive(Debug, Clone, Deserialize_repr, Serialize_repr)] -#[repr(u8)] -pub enum WebhookTypes { - Incoming = 1, - ChannelFollower = 2, - Application = 3, -} - -#[derive(Debug, Clone, Deserialize, Serialize)] -pub struct Webhook { - pub id: String, - #[serde(rename = "type")] - pub type_: WebhookTypes, - pub guild_id: Option, - pub channel_id: Option, - pub user: Option, - pub name: Option, - pub avatar: Option, - pub token: Option, - pub application_id: Option, - pub source_guild: Option, - pub source_channel: Option, - pub url: String, -} diff --git a/common/rust/src/lib.rs b/common/rust/src/lib.rs index fa2c6fc..cbe6934 100644 --- a/common/rust/src/lib.rs +++ b/common/rust/src/lib.rs @@ -9,10 +9,10 @@ pub use testcontainers; /// This crate is all the utilities shared by the nova rust projects /// It includes logging, config and protocols. pub mod config; -pub mod discord_models; pub mod error; pub mod monitoring; pub mod nats; pub mod payloads; pub mod redis; +mod serializable_event; diff --git a/common/rust/src/payloads.rs b/common/rust/src/payloads.rs index fd7717d..454baf1 100644 --- a/common/rust/src/payloads.rs +++ b/common/rust/src/payloads.rs @@ -1,27 +1,19 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; +use twilight_model::gateway::event::Event; +use crate::serializable_event::SerializableEvent; -use crate::discord_models::{ - application::Application, - channel::{Channel, Message, ThreadMember}, - emoji::Emoji, - gateway::PresenceUpdate, - guild::{Guild, GuildMember, Integration}, - invite::InviteTargetTypes, - permissions::Role, - slash_commands::{ApplicationCommand, Interaction}, - stage_instance::StageInstance, - user::User, - voice::VoiceState, -}; +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct SerializeHelper(#[serde(with = "SerializableEvent")] pub Event); /// Payload send to the nova cache queues #[derive(Serialize, Deserialize, Debug, Clone)] // #[serde(bound(deserialize = "T: Deserialize<'de> + std::default::Default + Clone"))] pub struct CachePayload { pub tracing: Tracing, - pub data: CacheData, + #[serde(flatten)] + pub data: SerializeHelper, } #[derive(Serialize, Deserialize, Debug, Clone)] @@ -29,242 +21,3 @@ pub struct Tracing { pub node_id: String, pub span: Option, } - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub enum CacheData { - Ready { - version: u8, - user: User, - guilds: Vec, - session_id: String, - shard: Option>, - application: Application, - }, - ApplicationCommandCreate { - guild_id: Option, - command: ApplicationCommand, - }, - ApplicationCommandUpdate { - guild_id: Option, - command: ApplicationCommand, - }, - ApplicationCommandDelete { - guild_id: Option, - command: ApplicationCommand, - }, - ChannelCreate { - channel: Channel, - }, - ChannelUpdate { - channel: Channel, - }, - ChannelDelete { - channel: Channel, - }, - ThreadCreate { - channel: Channel, - }, - ThreadUpdate { - channel: Channel, - }, - ThreadDelete { - channel: Channel, - }, - ThreadListSync { - guild_id: String, - channel_ids: Option>, - threads: Vec, - members: Vec, - }, - ThreadMemberUpdate { - member: ThreadMember, - }, - ThreadMembersUpdate { - id: String, - guild_id: String, - member_count: i64, - added_members: Option>, - removed_member_ids: Option>, - }, - ChannelPinsUpdate { - guild_id: Option, - channel_id: String, - last_pin_timestamp: Option, - }, - GuildCreate { - guild: Guild, - }, - GuildUpdate { - guild: Guild, - }, - GuildDelete { - guild: Guild, - }, - GuildBanAdd { - guild_id: String, - user: User, - }, - GuildBanRemove { - guild_id: String, - user: User, - }, - GuildEmojisUpdate { - guild_id: String, - emojis: Vec, - }, - GuildIntegrationsUpdate { - guild_id: String, - }, - GuildMemberAdd { - guild_id: String, - member: GuildMember, - }, - GuildMemberRemove { - guild_id: String, - user: User, - }, - GuildMemberUpdate { - guild_id: String, - roles: Vec, - user: User, - nick: Option, - joined_at: Option, - premium_since: Option, - deaf: Option, - mute: Option, - pending: Option, - }, - GuildMembersChunk { - guild_id: String, - members: Vec, - chunk_index: i64, - chunk_count: i64, - not_found: Option>, - presences: Option>, - nonce: Option, - }, - GuildRoleCreate { - guild_id: String, - role: Role, - }, - GuildRoleUpdate { - guild_id: String, - role: Role, - }, - GuildRoleDelete { - guild_id: String, - role_id: String, - }, - IntegrationCreate { - guild_id: String, - integration: Integration, - }, - IntegrationUpdate { - guild_id: String, - integration: Integration, - }, - IntegrationDelete { - id: String, - guild_id: String, - application_id: Option, - }, - InviteCreate { - channel_id: String, - code: String, - created_at: String, - guild_id: Option, - inviter: Option, - max_age: i64, - max_uses: i64, - target_type: Option, - target_user: Option, - target_application: Option, - temporary: bool, - uses: i64, - }, - InviteDelete { - channel_id: String, - guild_id: Option, - code: String, - }, - InteractionCreate { - // boxed to avoid a large difference size between variants (https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant) - interaction: Box, - }, - MessageCreate { - message: Message, - }, - MessageUpdate { - message: Message, - }, - MessageDelete { - id: String, - channel_id: String, - guild_id: Option, - }, - MessageDeleteBulk { - ids: Vec, - channel_id: String, - guild_id: Option, - }, - MessageReactionAdd { - user_id: String, - channel_id: String, - message_id: String, - guild_id: Option, - member: Option, - emoji: Emoji, - }, - MessageReactionRemove { - user_id: String, - channel_id: String, - message_id: String, - guild_id: Option, - emoji: Emoji, - }, - MessageReactionRemoveAll { - channel_id: String, - message_id: String, - guild_id: Option, - }, - MessageReactionRemoveEmoji { - channel_id: String, - message_id: String, - guild_id: Option, - emoji: Emoji, - }, - PresenceUpdate { - presence: PresenceUpdate, - }, - TypingStart { - channel_id: String, - guild_id: Option, - user_id: String, - timestamp: i64, - member: Option, - }, - UserUpdate { - user: User, - }, - VoiceStateUpdate { - state: VoiceState, - }, - VoiceServerUpdate { - token: String, - guild_id: String, - endpoint: Option, - }, - WebhookUpdate { - guild_id: String, - channel_id: String, - }, - StageInstanceCreate { - instance: StageInstance, - }, - StageInstanceUpdate { - instance: StageInstance, - }, - StageInstanceDelete { - instance: StageInstance, - }, -} diff --git a/common/rust/src/serializable_event.rs b/common/rust/src/serializable_event.rs new file mode 100644 index 0000000..269b0aa --- /dev/null +++ b/common/rust/src/serializable_event.rs @@ -0,0 +1,165 @@ +use serde::{Deserialize, Serialize}; +use twilight_model::gateway::{ + event::{ + shard::{ + Connected, Connecting, Disconnected, Identifying, Payload, Reconnecting, Resuming, + }, + Event, + }, + payload::{ + BanAdd, BanRemove, ChannelCreate, ChannelDelete, ChannelPinsUpdate, ChannelUpdate, + GuildCreate, GuildDelete, GuildEmojisUpdate, GuildIntegrationsUpdate, GuildUpdate, + IntegrationCreate, IntegrationDelete, IntegrationUpdate, InteractionCreate, InviteCreate, + InviteDelete, MemberAdd, MemberChunk, MemberRemove, MemberUpdate, MessageCreate, + MessageDelete, MessageDeleteBulk, MessageUpdate, PresenceUpdate, ReactionAdd, + ReactionRemove, ReactionRemoveAll, ReactionRemoveEmoji, Ready, RoleCreate, RoleDelete, + RoleUpdate, StageInstanceCreate, StageInstanceDelete, StageInstanceUpdate, ThreadCreate, + ThreadDelete, ThreadListSync, ThreadMemberUpdate, ThreadMembersUpdate, ThreadUpdate, + TypingStart, UnavailableGuild, UserUpdate, VoiceServerUpdate, VoiceStateUpdate, + WebhooksUpdate, + }, +}; + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(remote = "Event")] +#[serde(rename_all = "snake_case")] +#[serde(tag = "t", content = "c")] +pub enum SerializableEvent { + /// A user was banned from a guild. + BanAdd(BanAdd), + /// A user's ban from a guild was removed. + BanRemove(BanRemove), + /// A channel was created. + ChannelCreate(ChannelCreate), + /// A channel was deleted. + ChannelDelete(ChannelDelete), + /// A channel's pins were updated. + ChannelPinsUpdate(ChannelPinsUpdate), + /// A channel was updated. + ChannelUpdate(ChannelUpdate), + /// A heartbeat was sent to or received from the gateway. + GatewayHeartbeat(u64), + /// A heartbeat acknowledgement was received from the gateway. + GatewayHeartbeatAck, + /// A "hello" packet was received from the gateway. + GatewayHello(u64), + /// A shard's session was invalidated. + /// + /// `true` if resumeable. If not, then the shard must do a full reconnect. + GatewayInvalidateSession(bool), + /// The gateway is indicating to perform a reconnect. + GatewayReconnect, + /// Undocumented event, should be ignored + GiftCodeUpdate, + /// A guild was created. + GuildCreate(Box), + /// A guild was deleted or the current user was removed from a guild. + GuildDelete(Box), + /// A guild's emojis were updated. + GuildEmojisUpdate(GuildEmojisUpdate), + /// A guild's integrations were updated. + GuildIntegrationsUpdate(GuildIntegrationsUpdate), + /// A guild was updated. + GuildUpdate(Box), + /// A guild integration was created. + IntegrationCreate(Box), + /// A guild integration was updated. + IntegrationDelete(IntegrationDelete), + /// A guild integration was deleted. + IntegrationUpdate(Box), + /// An interaction was invoked by a user. + InteractionCreate(Box), + /// A invite was made. + InviteCreate(Box), + /// A invite was deleted. + InviteDelete(InviteDelete), + /// A user was added to a guild. + MemberAdd(Box), + /// A user was removed from a guild. + MemberRemove(MemberRemove), + /// A user's member object in a guild was updated. + MemberUpdate(Box), + /// A chunk of members were received from the gateway. + MemberChunk(MemberChunk), + /// A message was created in a channel. + MessageCreate(Box), + /// A message was deleted in a channel. + MessageDelete(MessageDelete), + /// Multiple messages were deleted in a channel. + MessageDeleteBulk(MessageDeleteBulk), + /// A message was updated in a channel. + MessageUpdate(Box), + /// A user's active presence (such as game or online status) was updated. + PresenceUpdate(Box), + /// Multiple presences outside of a guild were updated. + /// + /// For bots this is always empty and useless. + PresencesReplace, + /// A reaction was added to a message. + ReactionAdd(Box), + /// A reaction was removed from a message. + ReactionRemove(Box), + /// All reactions were removed from a message. + ReactionRemoveAll(ReactionRemoveAll), + /// All instances of a given emoji from the reactions of a message were + /// removed. + ReactionRemoveEmoji(ReactionRemoveEmoji), + /// A shard is now "ready" and fully connected. + Ready(Box), + /// A shard has successfully resumed. + Resumed, + /// A role was created in a guild. + RoleCreate(RoleCreate), + /// A role was deleted in a guild. + RoleDelete(RoleDelete), + /// A role was updated in a guild. + RoleUpdate(RoleUpdate), + /// A shard is now in a connected stage after being fully connected to the + /// gateway. + ShardConnected(Connected), + /// A shard is now in a connecting stage after starting to connect to the + /// gateway. + ShardConnecting(Connecting), + /// A shard is now in a disconnected stage after the connection was closed. + ShardDisconnected(Disconnected), + /// A shard is now in a identifying stage after starting a new session. + ShardIdentifying(Identifying), + /// A shard is now in a reconnecting stage after a disconnect or session was + /// ended. + ShardReconnecting(Reconnecting), + /// A payload of bytes came in through the shard's connection. + ShardPayload(Payload), + /// A shard is now in a Resuming stage after a disconnect. + ShardResuming(Resuming), + /// A stage instance was created in a stage channel. + StageInstanceCreate(StageInstanceCreate), + /// A stage instance was deleted in a stage channel. + StageInstanceDelete(StageInstanceDelete), + /// A stage instance was updated in a stage channel. + StageInstanceUpdate(StageInstanceUpdate), + /// A thread has been created, relevant to the current user, + /// or the current user has been added to a thread. + ThreadCreate(ThreadCreate), + /// A thread, relevant to the current user, has been deleted. + ThreadDelete(ThreadDelete), + /// The current user has gained access to a thread. + ThreadListSync(ThreadListSync), + /// The thread member object for the current user has been updated. + ThreadMemberUpdate(ThreadMemberUpdate), + /// A user has been added to or removed from a thread. + ThreadMembersUpdate(ThreadMembersUpdate), + /// A thread has been updated. + ThreadUpdate(ThreadUpdate), + /// A user started typing in a channel. + TypingStart(Box), + /// A guild is now unavailable. + UnavailableGuild(UnavailableGuild), + /// The current user was updated. + UserUpdate(UserUpdate), + /// A voice server update was sent. + VoiceServerUpdate(VoiceServerUpdate), + /// A voice state in a voice channel was updated. + VoiceStateUpdate(Box), + /// A webhook was updated. + WebhooksUpdate(WebhooksUpdate), +} diff --git a/gateway/BUILD b/gateway/BUILD index d65c913..c71c12e 100644 --- a/gateway/BUILD +++ b/gateway/BUILD @@ -7,10 +7,6 @@ test_suite(name = "tests") rust_binary( name = "gateway", srcs = glob(["src/**/*.rs"]), - proc_macro_deps = crate_deps([ - "serde_repr", - "num-derive", - ]), visibility = ["//visibility:public"], deps = all_crate_deps() + ["//common/rust:common"], ) diff --git a/gateway/Cargo.toml b/gateway/Cargo.toml index 4afdbc2..e1e6894 100644 --- a/gateway/Cargo.toml +++ b/gateway/Cargo.toml @@ -5,18 +5,8 @@ edition = "2018" [dependencies] common = { path = "../common/rust" } -tokio-tungstenite = { version = "*", features = ["rustls-tls"] } tokio = { version = "1", features = ["full"] } - -url = "2.2.2" -futures-util = "0.3.17" -futures = "0.3.17" - -serde_json = { version = "1.0" } -serde = { version = "1.0", features = ["derive"] } -serde_repr = "0.1" -enumflags2 = { version = "0.7.1", features = ["serde"] } - -num-traits = "0.2" -num-derive = "0.3" -num = "0.4" +twilight-gateway = { version = "0.6" } +serde = { version = "1.0.8", features = ["derive"] } +futures = "0.3" +serde_json = { version = "1.0" } \ No newline at end of file diff --git a/gateway/cargo/BUILD.bazel b/gateway/cargo/BUILD.bazel index e5271e2..8606080 100644 --- a/gateway/cargo/BUILD.bazel +++ b/gateway/cargo/BUILD.bazel @@ -12,15 +12,6 @@ licenses([ ]) # Aliased targets -alias( - name = "enumflags2", - actual = "@raze__enumflags2__0_7_1//:enumflags2", - tags = [ - "cargo-raze", - "manual", - ], -) - alias( name = "futures", actual = "@raze__futures__0_3_17//:futures", @@ -30,42 +21,6 @@ alias( ], ) -alias( - name = "futures_util", - actual = "@raze__futures_util__0_3_17//:futures_util", - tags = [ - "cargo-raze", - "manual", - ], -) - -alias( - name = "num", - actual = "@raze__num__0_4_0//:num", - tags = [ - "cargo-raze", - "manual", - ], -) - -alias( - name = "num_derive", - actual = "@raze__num_derive__0_3_3//:num_derive", - tags = [ - "cargo-raze", - "manual", - ], -) - -alias( - name = "num_traits", - actual = "@raze__num_traits__0_2_14//:num_traits", - tags = [ - "cargo-raze", - "manual", - ], -) - alias( name = "serde", actual = "@raze__serde__1_0_130//:serde", @@ -84,15 +39,6 @@ alias( ], ) -alias( - name = "serde_repr", - actual = "@raze__serde_repr__0_1_7//:serde_repr", - tags = [ - "cargo-raze", - "manual", - ], -) - alias( name = "tokio", actual = "@raze__tokio__1_12_0//:tokio", @@ -103,17 +49,8 @@ alias( ) alias( - name = "tokio_tungstenite", - actual = "@raze__tokio_tungstenite__0_15_0//:tokio_tungstenite", - tags = [ - "cargo-raze", - "manual", - ], -) - -alias( - name = "url", - actual = "@raze__url__2_2_2//:url", + name = "twilight_gateway", + actual = "@raze__twilight_gateway__0_6_5//:twilight_gateway", tags = [ "cargo-raze", "manual", diff --git a/gateway/src/config.rs b/gateway/src/config.rs new file mode 100644 index 0000000..999892b --- /dev/null +++ b/gateway/src/config.rs @@ -0,0 +1,14 @@ +use common::serde::{Deserialize, Serialize}; +use twilight_gateway::Intents; + +#[derive(Serialize, Deserialize, Clone)] +pub struct Config { + pub token: String, + pub intents: Intents +} + +impl Default for Config { + fn default() -> Self { + Self { intents: Intents::empty(), token: String::default() } + } +} diff --git a/gateway/src/connection/mod.rs b/gateway/src/connection/mod.rs deleted file mode 100644 index c60068a..0000000 --- a/gateway/src/connection/mod.rs +++ /dev/null @@ -1,36 +0,0 @@ -use tokio::net::TcpStream; -use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, connect_async, tungstenite::http::Request}; - -use crate::{error::GatewayError, utils::get_gateway_url}; - -mod stream; -mod utils; - -/// Underlying representation of a Discord event stream -/// that streams the Event payloads to the shard structure -pub struct Connection { - /// The channel given by tokio_tungstenite that represents the websocket connection - connection: Option>>, -} - -impl Connection { - pub fn new() -> Self { - Connection { connection: None } - } - - pub async fn start(&mut self) -> Result<(), GatewayError> { - let request = Request::builder() - .uri(get_gateway_url(false, "json", 9)) - .body(()) - .unwrap(); - - let connection_result = connect_async(request).await; - // we connect outselves to the websocket server - if let Err(err) = connection_result { - Err(GatewayError::from(err)) - } else { - self.connection = Some(connection_result.unwrap().0); - Ok(()) - } - } -} \ No newline at end of file diff --git a/gateway/src/connection/stream.rs b/gateway/src/connection/stream.rs deleted file mode 100644 index 5a12daf..0000000 --- a/gateway/src/connection/stream.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::{error::GatewayError, payloads::gateway::BaseMessage}; - -use super::Connection; -use futures::{FutureExt, Sink, SinkExt, Stream, StreamExt}; -use common::log::info; -use serde::Serialize; -use std::{ - pin::Pin, - task::{Context, Poll}, -}; -use tokio_tungstenite::tungstenite::Message; - -/// Implementation of the Stream trait for the Connection -impl Stream for Connection { - type Item = Result; - - fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - // first, when a poll is called, we check if the connection is still open - if let Some(conn) = &mut self.connection { - // we need to wait poll the message using the tokio_tungstenite stream - let message = conn.poll_next_unpin(cx); - - match message { - Poll::Ready(packet) => { - // if data is available, we can continue - match packet { - Some(result) => match result { - Ok(message) => { - match Box::pin(self._handle_message(&message)).poll_unpin(cx) { - Poll::Ready(data) => match data { - Ok(d) => Poll::Ready(Some(Ok(d))), - Err(e) => Poll::Ready(Some(Err(e))), - }, - // unknown behaviour? - Poll::Pending => unreachable!(), - } - } - Err(e) => Poll::Ready(Some(Err(GatewayError::from(e)))), - }, - // if no message is available, we return none, it's the end of the stream - None => { - info!("tokio_tungstenite stream finished successfully"); - let _ = Box::pin(conn.close(None)).poll_unpin(cx); - self.connection = None; - Poll::Ready(None) - } - } - } - // if the message is pending, we return the same result - Poll::Pending => Poll::Pending, - } - } else { - Poll::Ready(None) - } - } -} - -/// Implementation of the Sink trait for the Connection -impl Sink> for Connection { - type Error = tokio_tungstenite::tungstenite::Error; - - #[allow(dead_code)] - fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if let Some(conn) = &mut self.connection { - // a connection exists, we can send data - conn.poll_ready_unpin(cx) - } else { - Poll::Pending - } - } - - #[allow(dead_code)] - fn start_send(mut self: Pin<&mut Self>, item: BaseMessage) -> Result<(), Self::Error> { - if let Some(conn) = &mut self.connection { - let message = serde_json::to_string(&item); - conn.start_send_unpin(Message::Text(message.unwrap())) - .unwrap(); - } - Ok(()) - } - - #[allow(dead_code)] - fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if let Some(conn) = &mut self.connection { - conn.poll_flush_unpin(cx) - } else { - Poll::Pending - } - } - - #[allow(dead_code)] - fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { - if let Some(conn) = &mut self.connection { - conn.poll_close_unpin(cx) - } else { - Poll::Pending - } - } -} diff --git a/gateway/src/connection/utils.rs b/gateway/src/connection/utils.rs deleted file mode 100644 index bb425da..0000000 --- a/gateway/src/connection/utils.rs +++ /dev/null @@ -1,42 +0,0 @@ -use std::str::from_utf8; -use tokio_tungstenite::tungstenite::Message; -use common::log::info; - -use crate::error::GatewayError; - -use super::Connection; - -impl Connection { - - /// Handles the websocket events and calls the _handle_discord_message function for the deserialization. - pub(super) async fn _handle_message( - &mut self, - data: &Message, - ) -> Result { - match data { - Message::Text(text) => self._handle_discord_message(&text).await, - Message::Binary(message) => { - match from_utf8(message) { - Ok(data) => self._handle_discord_message(data).await, - Err(err) => Err(GatewayError::from(err.to_string())), - } - }, - Message::Close(close_frame) => { - info!("Discord connection closed {:?}", close_frame); - Err(GatewayError::from("connection closed".to_string())) - }, - _ => Err(GatewayError::from(format!("unknown variant of message specified to the handler {}", data).to_string())), - } - } - - /// Handle the decompression and deserialization process of a discord payload. - pub(super) async fn _handle_discord_message( - &mut self, - raw_message: &str, - ) -> Result { - match serde_json::from_str(raw_message) { - Ok(message) => Ok(message), - Err(err) => Err(GatewayError::from(err.to_string())), - } - } -} diff --git a/gateway/src/error.rs b/gateway/src/error.rs deleted file mode 100644 index eb3a245..0000000 --- a/gateway/src/error.rs +++ /dev/null @@ -1,22 +0,0 @@ -use common::error::NovaError; - -#[derive(Debug)] -pub struct GatewayError(NovaError); - -impl From for GatewayError { - fn from(e: tokio_tungstenite::tungstenite::Error) -> Self { - GatewayError { - 0: NovaError { - message: e.to_string(), - }, - } - } -} - -impl From for GatewayError { - fn from(e: String) -> Self { - GatewayError { - 0: NovaError { message: e }, - } - } -} diff --git a/gateway/src/main.rs b/gateway/src/main.rs index 4c42c7a..4f67183 100644 --- a/gateway/src/main.rs +++ b/gateway/src/main.rs @@ -1,19 +1,60 @@ -use common::config::Settings; -use shard::{Shard, ShardConfig}; -#[macro_use] -extern crate num_derive; +use common::{ + config::Settings, + log::{debug, info}, + nats_crate::Connection, + payloads::{CachePayload, SerializeHelper, Tracing}, +}; +use config::Config; +use std::error::Error; +use twilight_gateway::{Event, Shard}; +mod config; +use futures::StreamExt; -pub mod connection; -mod error; -mod utils; -mod shard; -mod payloads; +#[tokio::main] +async fn main() -> Result<(), Box> { + let settings: Settings = Settings::new("gateway").unwrap(); + let (shard, mut events) = Shard::new(settings.config.token, settings.config.intents); + let nats: Connection = settings.nats.into(); + shard.start().await?; + while let Some(event) = events.next().await { + match event { + Event::Ready(ready) => { + info!("Logged in as {}", ready.user.name); + } + Event::Resumed => {} + Event::GatewayHeartbeat(_) => {} + Event::GatewayHeartbeatAck => {} + Event::GatewayInvalidateSession(_) => {} + Event::GatewayReconnect => {} + Event::GatewayHello(_) => {} -#[tokio::main] -async fn main() { - let settings: Settings = Settings::new("gateway").unwrap(); - let mut shard = Shard::new(settings.config); - shard.start().await; + Event::ShardConnected(_) => {} + Event::ShardConnecting(_) => {} + Event::ShardDisconnected(_) => {} + Event::ShardIdentifying(_) => {} + Event::ShardReconnecting(_) => {} + Event::ShardPayload(_) => {} + Event::ShardResuming(_) => {} + + _ => { + let data = CachePayload { + tracing: Tracing { + node_id: "".to_string(), + span: None, + }, + data: SerializeHelper(event), + }; + let value = serde_json::to_string(&data)?; + debug!("nats send: {}", value); + nats.request( + &format!("nova.cache.discord.{}", data.data.0.kind().name().unwrap()), + value, + )?; + } + } + } + + Ok(()) } diff --git a/gateway/src/payloads/dispatch.rs b/gateway/src/payloads/dispatch.rs deleted file mode 100644 index 9eca9c5..0000000 --- a/gateway/src/payloads/dispatch.rs +++ /dev/null @@ -1,46 +0,0 @@ -use serde::{Deserialize, Deserializer, Serialize}; - -use serde_json::Value; - -use super::gateway::BaseMessage; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] -pub struct Ready { - #[serde(rename = "v")] - pub version: u64, - pub user: Value, - pub guilds: Vec, - pub session_id: String, - pub shard: Option<[i64;2]>, - pub application: Value, -} - -#[derive(Clone, Debug, PartialEq, Deserialize)] -#[serde(tag = "t", content = "d")] -pub enum FakeDispatch { - #[serde(rename = "READY")] - Ready(Ready), - Other(Value), -} - -#[derive(Clone, Debug, PartialEq)] -pub enum Dispatch { - Ready(Ready), - Other(BaseMessage) -} - -impl<'de> Deserialize<'de> for Dispatch { - fn deserialize(d: D) -> Result - where - D: Deserializer<'de>, - { - // todo: error handling - let value = Value::deserialize(d)?; - - if value.get("t").unwrap() == "READY" { - Ok(Dispatch::Ready(Ready::deserialize(value.get("d").unwrap()).unwrap())) - } else { - Ok(Dispatch::Other(BaseMessage::deserialize(value).unwrap())) - } - } -} \ No newline at end of file diff --git a/gateway/src/payloads/events/mod.rs b/gateway/src/payloads/events/mod.rs deleted file mode 100644 index 3fef2d9..0000000 --- a/gateway/src/payloads/events/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod ready; \ No newline at end of file diff --git a/gateway/src/payloads/events/ready.rs b/gateway/src/payloads/events/ready.rs deleted file mode 100644 index a5ec291..0000000 --- a/gateway/src/payloads/events/ready.rs +++ /dev/null @@ -1,13 +0,0 @@ -use serde::Deserialize; -use serde_json::Value; - -#[derive(Deserialize, Clone, Debug, PartialEq)] -pub struct Ready { - #[serde(rename = "v")] - pub version: u64, - pub user: Value, - pub guilds: Vec, - pub session_id: String, - pub shard: Option<[i64;2]>, - pub application: Value, -} diff --git a/gateway/src/payloads/gateway.rs b/gateway/src/payloads/gateway.rs deleted file mode 100644 index 4f24890..0000000 --- a/gateway/src/payloads/gateway.rs +++ /dev/null @@ -1,78 +0,0 @@ -use super::{ - dispatch::Dispatch, - opcodes::{hello::Hello, OpCodes}, -}; -use serde::de::Error; -use serde::{Deserialize, Serialize}; -use serde_json::Value; - -#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] -#[serde(bound(deserialize = "T: Deserialize<'de> + std::fmt::Debug"))] -pub struct BaseMessage { - pub t: Option, - #[serde(rename = "s")] - pub sequence: Option, - pub op: OpCodes, - #[serde(rename = "d")] - pub data: T, -} - -#[derive(Debug)] -pub enum Message { - Dispatch(BaseMessage), - Reconnect(BaseMessage<()>), - InvalidSession(BaseMessage), - Hello(BaseMessage), - HeartbeatACK(BaseMessage<()>), -} - -impl<'de> serde::Deserialize<'de> for Message { - fn deserialize>(d: D) -> Result - where - D::Error: Error, - { - let value = Value::deserialize(d)?; - let val = value.get("op").and_then(Value::as_u64).unwrap(); - - if let Some(op) = num::FromPrimitive::from_u64(val) { - match op { - OpCodes::Dispatch => { - // todo: remove unwrap - let t = Some(value.get("t").unwrap().to_string()); - let sequence = value.get("s").unwrap().as_u64(); - - // we need to find a better solution than clone - match Dispatch::deserialize(value) { - Ok(data) => Ok(Message::Dispatch(BaseMessage { - op, - t, - sequence, - data, - })), - Err(e) => Err(Error::custom(e)), - } - } - - OpCodes::Reconnect => match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::Reconnect(data)), - Err(e) => Err(Error::custom(e)), - }, - OpCodes::InvalidSession => match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::InvalidSession(data)), - Err(e) => Err(Error::custom(e)), - }, - OpCodes::Hello => match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::Hello(data)), - Err(e) => Err(Error::custom(e)), - }, - OpCodes::HeartbeatACK => match BaseMessage::deserialize(value) { - Ok(data) => Ok(Message::HeartbeatACK(data)), - Err(e) => Err(Error::custom(e)), - }, - _ => panic!("Cannot convert"), - } - } else { - Err(Error::custom("unknown opcode")) - } - } -} diff --git a/gateway/src/payloads/mod.rs b/gateway/src/payloads/mod.rs deleted file mode 100644 index e9849a7..0000000 --- a/gateway/src/payloads/mod.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub mod opcodes; -pub mod dispatch; -pub mod gateway; -pub mod events; diff --git a/gateway/src/payloads/opcodes/hello.rs b/gateway/src/payloads/opcodes/hello.rs deleted file mode 100644 index 3d8fd0f..0000000 --- a/gateway/src/payloads/opcodes/hello.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::{Serialize, Deserialize}; - -/// The first message sent by the gateway to initialize the heartbeating -#[derive(Debug, Serialize, Deserialize)] -pub struct Hello { - #[serde(rename = "heartbeat_interval")] - pub heartbeat_interval: u64 -} diff --git a/gateway/src/payloads/opcodes/identify.rs b/gateway/src/payloads/opcodes/identify.rs deleted file mode 100644 index 5929c33..0000000 --- a/gateway/src/payloads/opcodes/identify.rs +++ /dev/null @@ -1,47 +0,0 @@ -use enumflags2::{BitFlags, bitflags}; -use serde::{Deserialize, Serialize}; -use super::presence::PresenceUpdate; - - -#[bitflags] -#[repr(u16)] -#[derive(Clone, Copy, Debug)] -pub enum Intents { - Guilds = 1 << 0, - GuildMembers = 1 << 1, - GuildBans = 1 << 2, - GuildEmojisAndStickers = 1 << 3, - GuildIntegrations = 1 << 4, - GuildWebhoks = 1 << 5, - GuildInvites = 1 << 6, - GuildVoiceStates = 1 << 7, - GuildPresences = 1 << 8, - GuildMessages = 1 << 9, - GuildMessagesReactions = 1 << 10, - GuildMessageTyping = 1 << 11, - DirectMessages = 1 << 12, - DirectMessagesReactions = 1 << 13, - DirectMessageTyping = 1 << 14, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct IdentifyProprerties { - #[serde(rename = "$os")] - pub os: String, - #[serde(rename = "$browser")] - pub browser: String, - #[serde(rename = "$device")] - pub device: String, -} - -/// Messages sent by the shard to log-in to the gateway. -#[derive(Debug, Serialize, Deserialize)] -pub struct Identify { - pub token: String, - pub properties: IdentifyProprerties, - pub compress: Option, - pub large_threshold: Option, - pub shard: Option<[u64; 2]>, - pub presence: Option, - pub intents: BitFlags, -} \ No newline at end of file diff --git a/gateway/src/payloads/opcodes/mod.rs b/gateway/src/payloads/opcodes/mod.rs deleted file mode 100644 index cfa453a..0000000 --- a/gateway/src/payloads/opcodes/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -pub mod hello; -pub mod identify; -pub mod resume; -pub mod presence; -use serde_repr::{Deserialize_repr, Serialize_repr}; - -#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, FromPrimitive, ToPrimitive)] -#[repr(u8)] - -pub enum OpCodes { - Dispatch = 0, - Heartbeat = 1, - Identify = 2, - PresenceUpdate = 3, - VoiceStateUpdate = 4, - Resume = 6, - Reconnect = 7, - RequestGuildMembers = 8, - InvalidSession = 9, - Hello = 10, - HeartbeatACK = 11, -} \ No newline at end of file diff --git a/gateway/src/payloads/opcodes/presence.rs b/gateway/src/payloads/opcodes/presence.rs deleted file mode 100644 index a6c5773..0000000 --- a/gateway/src/payloads/opcodes/presence.rs +++ /dev/null @@ -1,63 +0,0 @@ -use serde_repr::{Deserialize_repr, Serialize_repr}; -use serde::{Deserialize, Serialize}; -#[derive(Serialize_repr, Deserialize_repr, Debug)] -#[repr(u8)] -pub enum ActivityType { - Game = 0, - Streaming = 1, - Listening = 2, - Watching = 3, - Custom = 4, - Competing = 5 -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct ActivityTimestamps { - start: u64, - end: u64, -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct ActivityEmoji { - name: String, - id: Option, - animated: Option -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct Activity { - name: String, - #[serde(rename = "type")] - t: ActivityType, - - url: Option, - created_at: i64, - timestamp: Option, - application_id: Option, - details: Option, - state: Option, - emoji: Option, - // todo: implement more -} - -#[derive(Serialize, Deserialize, Debug)] -pub enum PresenceStatus { - #[serde(rename = "online")] - Online, - #[serde(rename = "dnd")] - Dnd, - #[serde(rename = "idle")] - Idle, - #[serde(rename = "invisible")] - Invisible, - #[serde(rename = "offline")] - Offline -} - -#[derive(Serialize, Deserialize, Debug)] -pub struct PresenceUpdate { - since: u64, - activities: Vec, - status: PresenceStatus, - afk: bool, -} diff --git a/gateway/src/payloads/opcodes/resume.rs b/gateway/src/payloads/opcodes/resume.rs deleted file mode 100644 index e1bba91..0000000 --- a/gateway/src/payloads/opcodes/resume.rs +++ /dev/null @@ -1,8 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Serialize, Deserialize)] -pub struct Resume { - pub token: String, - pub session_id: String, - pub seq: u64, -} \ No newline at end of file diff --git a/gateway/src/shard/actions.rs b/gateway/src/shard/actions.rs deleted file mode 100644 index 39a7ca2..0000000 --- a/gateway/src/shard/actions.rs +++ /dev/null @@ -1,132 +0,0 @@ -use std::env; - -use futures::SinkExt; -use common::log::{debug, error, info}; -use serde::Serialize; -use serde_json::Value; -use std::fmt::Debug; - -use crate::{ - error::GatewayError, - payloads::{ - gateway::BaseMessage, - opcodes::{ - identify::{Identify, IdentifyProprerties}, - presence::PresenceUpdate, - resume::Resume, - OpCodes, - }, - }, -}; - -use super::Shard; - -/// Implement the available actions for nova in the gateway. -impl Shard { - /// sends a message through the websocket - pub async fn _send( - &mut self, - message: BaseMessage, - ) -> Result<(), GatewayError> { - debug!("Senging message {:?}", message); - if let Some(connection) = &mut self.connection { - if let Err(e) = connection.conn.send(message).await { - error!("failed to send message {:?}", e); - Err(GatewayError::from(e)) - } else { - Ok(()) - } - } else { - Err(GatewayError::from("no open connection".to_string())) - } - } - - pub async fn _identify(&mut self) -> Result<(), GatewayError> { - if let Some(state) = self.state.clone() { - info!("Using session"); - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::Resume, - data: Resume { - token: self.config.token.clone(), - seq: state.sequence, - session_id: state.session_id.clone(), - }, - }) - .await - } else { - info!("Sending login"); - let mut shards: Option<[u64; 2]> = None; - if let Some(sharding) = self.config.shard.as_ref() { - shards = Some([sharding.current_shard, sharding.total_shards]); - } - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::Identify, - data: Identify { - token: self.config.token.clone(), - intents: self.config.intents, - properties: IdentifyProprerties { - os: env::consts::OS.to_string(), - browser: "Nova".to_string(), - device: "Nova".to_string(), - }, - shard: shards, - compress: Some(false), - large_threshold: Some(500), - presence: None, - }, - }) - .await - } - } - - pub async fn _disconnect(&mut self) {} - - /// Updates the presence of the current shard. - #[allow(dead_code)] - pub async fn presence_update(&mut self, update: PresenceUpdate) -> Result<(), GatewayError> { - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::PresenceUpdate, - data: update, - }) - .await - } - /// Updates the voice status of the current shard in a certain channel. - #[allow(dead_code)] - pub async fn voice_state_update(&mut self) -> Result<(), GatewayError> { - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::VoiceStateUpdate, - // todo: proper payload for this - data: Value::Null, - }) - .await - } - /// Ask discord for more informations about offline guild members. - #[allow(dead_code)] - pub async fn request_guild_members(&mut self) -> Result<(), GatewayError> { - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::RequestGuildMembers, - // todo: proper payload for this - data: Value::Null, - }) - .await - } - - pub async fn _send_heartbeat(&mut self) -> Result<(), GatewayError> { - self._send(BaseMessage { - t: None, - sequence: None, - op: OpCodes::Heartbeat, - data: self.state.as_ref().unwrap().sequence - }).await - } -} diff --git a/gateway/src/shard/connection.rs b/gateway/src/shard/connection.rs deleted file mode 100644 index 8f8ddc6..0000000 --- a/gateway/src/shard/connection.rs +++ /dev/null @@ -1,193 +0,0 @@ -use std::{cmp::min, convert::TryInto, time::Duration}; - -use crate::{connection::Connection, error::GatewayError, payloads::{ - dispatch::Dispatch, - gateway::{BaseMessage, Message}, - }, shard::state::SessionState}; - -use super::{state::ConnectionState, ConnectionWithState, Shard}; -use futures::StreamExt; -use common::log::{error, info}; -use tokio::{select, time::{Instant, interval_at, sleep}}; - -impl Shard { - pub async fn start(self: &mut Self) { - let mut reconnects = 1; - info!("Starting shard"); - - while reconnects < self.config.max_reconnects { - info!("Starting connection for shard"); - if let Err(e) = self._shard_task().await { - error!("Gateway status: {:?}", e); - } - // when the shard got disconnected, the shard task ends - reconnects += 1; - - // wait reconnects min(max(reconnects * reconnect_delay_growth_factor, reconnect_delay_minimum),reconnect_delay_maximum) - if reconnects < self.config.max_reconnects { - let time = min( - self.config.reconnect_delay_maximum, - self.config.reconnect_delay_minimum * (((reconnects - 1) as f32) * self.config.reconnect_delay_growth_factor) as usize, - ); - info!( - "The shard got disconnected, waiting for reconnect ({}ms)", - time - ); - sleep(Duration::from_millis(time.try_into().unwrap())).await; - } - } - info!( - "The shard got disconnected too many times and reached the maximum {}", - self.config.max_reconnects - ); - } - - async fn _shard_task(&mut self) -> Result<(), GatewayError> { - // create the new connection - let mut connection = Connection::new(); - connection.start().await.unwrap(); - self.connection = Some(ConnectionWithState { - conn: connection, - state: ConnectionState::new(), - }); - - loop { - if let Some(connection) = &mut self.connection { - if let Some(timer) = &mut connection.state.interval { - select!( - payload = connection.conn.next() => { - match payload { - Some(data) => match data { - Ok(message) => self._handle(&message).await, - Err(error) => { - return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string())); - }, - }, - None => { - return Err(GatewayError::from("Connection terminated".to_string())); - }, - } - }, - _ = timer.tick() => match self._do_heartbeat().await { - Ok(_) => {}, - Err(error) => { - return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string())); - }, - } - ) - } else { - select!( - payload = connection.conn.next() => { - match payload { - Some(data) => match data { - Ok(message) => self._handle(&message).await, - Err(error) => { - return Err(GatewayError::from(format!("An error occured while being connected to Discord: {:?}", error).to_string())); - }, - }, - None => { - return Err(GatewayError::from("Connection terminated".to_string())); - }, - } - } - ) - } - - } - } - } - - async fn _do_heartbeat(&mut self) -> Result<(), GatewayError> { - info!("heartbeat sent"); - if let Some(conn) = &mut self.connection { - if !conn.state.last_heartbeat_acknowledged { - error!("we missed a hertbeat"); - Err(GatewayError::from("a hertbeat was dropped, we need to restart the connection".to_string())) - } else { - conn.state.last_heartbeat_acknowledged = false; - conn.state.last_heartbeat_time = Instant::now(); - self._send_heartbeat().await - } - } else { - unreachable!() - } - } - - fn _util_set_seq(&mut self, seq: Option) { - if let Some(seq) = seq { - if let Some(state) = &mut self.state { - state.sequence = seq; - } - } - } - - async fn _handle(&mut self, message: &Message) { - match message { - Message::Dispatch(msg) => { - self._util_set_seq(msg.sequence); - self._dispatch(&msg).await; - } - // we need to reconnect to the gateway - Message::Reconnect(msg) => { - self._util_set_seq(msg.sequence); - info!("Gateway disconnect requested"); - self._disconnect().await; - } - Message::InvalidSession(msg) => { - self._util_set_seq(msg.sequence); - info!("invalid session"); - let data = msg.data; - if !data { - info!("Session removed"); - // reset the session data - self.state = None; - if let Err(e) = self._identify().await { - error!("Error while sending identify: {:?}", e); - } - } - } - Message::HeartbeatACK(msg) => { - info!("Heartbeat ack received"); - self._util_set_seq(msg.sequence); - if let Some(conn) = &mut self.connection { - conn.state.last_heartbeat_acknowledged = true; - let latency = Instant::now() - conn.state.last_heartbeat_time; - info!("Latency updated {}ms", latency.as_millis()); - } - } - Message::Hello(msg) => { - info!("Server hello received"); - self._util_set_seq(msg.sequence); - if let Some(conn) = &mut self.connection { - conn.state.interval = Some(interval_at( - Instant::now() + Duration::from_millis(msg.data.heartbeat_interval), - Duration::from_millis(msg.data.heartbeat_interval), - )); - } - - if let Err(e) = self._identify().await { - error!("error while sending identify: {:?}", e); - } - }, - } - } - - async fn _dispatch(&mut self, dispatch: &BaseMessage) { - match &dispatch.data { - Dispatch::Ready(ready) => { - info!("Received gateway dispatch ready"); - info!( - "Logged in as {}", - ready.user.get("username").unwrap().to_string() - ); - self.state = Some(SessionState { - sequence: dispatch.sequence.unwrap(), - session_id: ready.session_id.clone(), - }); - } - Dispatch::Other(_data) => { - // todo: build dispatch & forward to nats - } - } - } -} diff --git a/gateway/src/shard/mod.rs b/gateway/src/shard/mod.rs deleted file mode 100644 index 55828d0..0000000 --- a/gateway/src/shard/mod.rs +++ /dev/null @@ -1,49 +0,0 @@ -use enumflags2::BitFlags; -use serde::{Deserialize, Serialize}; -use crate::{connection::Connection, payloads::opcodes::identify::Intents}; -use self::state::{ConnectionState, SessionState}; -mod actions; -mod connection; -mod state; - -#[derive(Debug, Deserialize, Serialize, Default, Clone)] -pub struct Sharding { - pub total_shards: u64, - pub current_shard: u64 -} - -#[derive(Debug, Deserialize, Serialize, Default, Clone)] -pub struct ShardConfig { - pub max_reconnects: usize, - pub reconnect_delay_growth_factor: f32, - pub reconnect_delay_minimum: usize, - pub reconnect_delay_maximum: usize, - pub token: String, - - pub large_threshold: Option, - pub shard: Option, - pub intents: BitFlags -} - -struct ConnectionWithState { - conn: Connection, - state: ConnectionState, -} - -/// Represents a shard & all the reconnection logic related to it -pub struct Shard { - connection: Option, - state: Option, - config: ShardConfig -} - -impl Shard { - /// Creates a new shard instance - pub fn new(config: ShardConfig) -> Self { - Shard { - connection: None, - state: None, - config, - } - } -} diff --git a/gateway/src/shard/state.rs b/gateway/src/shard/state.rs deleted file mode 100644 index 34b7acc..0000000 --- a/gateway/src/shard/state.rs +++ /dev/null @@ -1,35 +0,0 @@ -use tokio::time::{Instant, Interval}; - -/// This struct represents the state of a session -#[derive(Clone, Debug)] -pub struct SessionState { - pub sequence: u64, - pub session_id: String, -} - -impl Default for SessionState { - fn default() -> Self { - Self { - sequence: Default::default(), - session_id: Default::default(), - } - } -} - -/// This struct represents the state of a connection -#[derive(Debug)] -pub struct ConnectionState { - pub last_heartbeat_acknowledged: bool, - pub last_heartbeat_time: Instant, - pub interval: Option, - -} -impl ConnectionState { - pub fn new() -> Self { - Self { - last_heartbeat_acknowledged: true, - last_heartbeat_time: Instant::now(), - interval: None, - } - } -} \ No newline at end of file diff --git a/gateway/src/utils.rs b/gateway/src/utils.rs deleted file mode 100644 index 48a9aed..0000000 --- a/gateway/src/utils.rs +++ /dev/null @@ -1,8 +0,0 @@ -/// Formats a url of connection to the gateway -pub fn get_gateway_url (compress: bool, encoding: &str, v: i16) -> String { - return format!( - "wss://gateway.discord.gg/?v={}&encoding={}&compress={}", - v, encoding, - if compress { "zlib-stream" } else { "" } - ); -} \ No newline at end of file diff --git a/webhook/Cargo.toml b/webhook/Cargo.toml index 24c68f8..e4c8075 100644 --- a/webhook/Cargo.toml +++ b/webhook/Cargo.toml @@ -14,6 +14,7 @@ libc = "0.2.101" lazy_static = "1.4.0" ctor = "0.1.21" ed25519-dalek = "1" +twilight-model = { version = "0.6" } rand = "0.7" [[bin]] diff --git a/webhook/cargo/BUILD.bazel b/webhook/cargo/BUILD.bazel index 77bc34f..0d8caf1 100644 --- a/webhook/cargo/BUILD.bazel +++ b/webhook/cargo/BUILD.bazel @@ -101,3 +101,12 @@ alias( "manual", ], ) + +alias( + name = "twilight_model", + actual = "@raze__twilight_model__0_6_5//:twilight_model", + tags = [ + "cargo-raze", + "manual", + ], +) diff --git a/webhook/src/handler/error.rs b/webhook/src/handler/error.rs index f998b84..d4fee07 100644 --- a/webhook/src/handler/error.rs +++ b/webhook/src/handler/error.rs @@ -1,4 +1,4 @@ -use hyper::{Body, Response, StatusCode}; +use hyper::{header::ToStrError, Body, Response, StatusCode}; pub struct WebhookError { pub code: StatusCode, @@ -22,3 +22,15 @@ impl Into> for WebhookError { .unwrap() } } + +impl From for WebhookError { + fn from(_: hyper::Error) -> Self { + WebhookError::new(StatusCode::BAD_REQUEST, "invalid request") + } +} + +impl From for WebhookError { + fn from(_: ToStrError) -> Self { + WebhookError::new(StatusCode::BAD_REQUEST, "invalid request") + } +} diff --git a/webhook/src/handler/handler.rs b/webhook/src/handler/handler.rs index e54b5ee..97300e4 100644 --- a/webhook/src/handler/handler.rs +++ b/webhook/src/handler/handler.rs @@ -1,10 +1,10 @@ use super::error::WebhookError; use super::signature::validate_signature; use crate::config::Config; -use common::discord_models::slash_commands::{Interaction, InteractionRequestType}; use common::log::{debug, error}; use common::nats_crate::Connection; -use common::payloads::CacheData; +use common::payloads::SerializeHelper; +use ed25519_dalek::PublicKey; use hyper::{ body::{to_bytes, Bytes}, service::Service, @@ -19,54 +19,50 @@ use std::{ task::{Context, Poll}, time::Duration, }; -use ed25519_dalek::PublicKey; +use twilight_model::application::interaction::Interaction; +use twilight_model::gateway::event::Event; +use twilight_model::gateway::payload::InteractionCreate; /// Hyper service used to handle the discord webhooks #[derive(Clone)] pub struct HandlerService { pub config: Arc, pub nats: Arc, - pub public_key: Arc + pub public_key: Arc, } impl HandlerService { async fn check_request(&self, req: Request) -> Result { if req.method() == Method::POST { - let headers = req.headers().clone(); - let signature = headers.get("X-Signature-Ed25519"); - let timestamp = headers.get("X-Signature-Timestamp"); - if let (Some(timestamp), Some(signature)) = (timestamp, signature) { - if let Ok(data) = to_bytes(req.into_body()).await { - let contatenated_data = [timestamp.as_bytes().to_vec(), data.to_vec()].concat(); - if let Ok(signature_str) = &signature.to_str() { - if validate_signature( - &self.public_key, - &contatenated_data, - signature_str, - ) { - Ok(data) - } else { - Err(WebhookError::new( - StatusCode::UNAUTHORIZED, - "invalid signature", - )) - } - } else { - Err(WebhookError::new( - StatusCode::BAD_REQUEST, - "failed to read signature", - )) - } - } else { - Err(WebhookError::new( - StatusCode::BAD_REQUEST, - "unable to read body", - )) - } + let signature = if let Some(sig) = req.headers().get("X-Signature-Ed25519") { + sig.to_owned() + } else { + return Err(WebhookError::new( + StatusCode::BAD_REQUEST, + "missing signature header", + )); + }; + + let timestamp = if let Some(timestamp) = req.headers().get("X-Signature-Timestamp") { + timestamp.to_owned() + } else { + return Err(WebhookError::new( + StatusCode::BAD_REQUEST, + "missing timestamp header", + )); + }; + let data = to_bytes(req.into_body()).await?; + + if validate_signature( + &self.public_key, + &[timestamp.as_bytes().to_vec(), data.to_vec()].concat(), + signature.to_str()?, + ) { + Ok(data) } else { Err(WebhookError::new( StatusCode::UNAUTHORIZED, - "missing signature headers", + "invalid signature", )) } } else { @@ -83,8 +79,8 @@ impl HandlerService { let utf8 = from_utf8(&data); match utf8 { Ok(data) => match serde_json::from_str::(data) { - Ok(value) => match value.type_ { - InteractionRequestType::Ping => Ok(Response::builder() + Ok(value) => match value { + Interaction::Ping(_) => Ok(Response::builder() .header("Content-Type", "application/json") .body(serde_json::to_string(&Ping { t: 1 }).unwrap().into()) .unwrap()), @@ -97,9 +93,9 @@ impl HandlerService { node_id: "".to_string(), span: None, }, - data: CacheData::InteractionCreate { - interaction: Box::new(value), - }, + data: SerializeHelper(Event::InteractionCreate( + Box::new(InteractionCreate(value)), + )), }) .unwrap(); @@ -127,10 +123,10 @@ impl HandlerService { Err(error) => { error!("invalid json body: {}", error); Err(WebhookError::new( - StatusCode::BAD_REQUEST, - "invalid json body", + StatusCode::BAD_REQUEST, + "invalid json body", )) - }, + } }, Err(_) => Err(WebhookError::new(StatusCode::BAD_REQUEST, "not utf-8 body")), diff --git a/webhook/src/handler/tests/handler_integration.rs b/webhook/src/handler/tests/handler_integration.rs index 906b347..b5204fb 100644 --- a/webhook/src/handler/tests/handler_integration.rs +++ b/webhook/src/handler/tests/handler_integration.rs @@ -101,7 +101,7 @@ unsafe fn destroy() { #[tokio::test] async fn respond_to_pings() { - let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string(); + let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1, "channel_id": "123" }).to_string(); let timestamp = "my datetime :)"; let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat(); let signature = sign_message(signature_data, &TEST_KEYPAIR); @@ -113,6 +113,7 @@ async fn respond_to_pings() { .header("X-Signature-Timestamp", timestamp) .body(Body::from(ping.clone())) .expect("request builder"); + let client = hyper::client::Client::new(); let result = client.request(req).await.unwrap(); @@ -121,7 +122,7 @@ async fn respond_to_pings() { #[tokio::test] async fn deny_invalid_signatures() { - let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string(); + let ping = json!({ "type": 1, "id": "0", "application_id": "0", "token": "random token", "version": 1, "channel_id": "123" }).to_string(); let timestamp = "my datetime :)"; let req = Request::builder() @@ -138,7 +139,19 @@ async fn deny_invalid_signatures() { #[tokio::test] async fn response_500_when_no_nats_response() { - let ping = json!({ "type": 2, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string(); + let ping = json!({ + "type": 2, + "id": "0", + "application_id": "0", + "token": "random token", + "version": 1, + "channel_id": "123", + "data": { + "id": "0", + "name": "command" + } + }).to_string(); + let timestamp = "my datetime :)"; let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat(); let signature = sign_message(signature_data, &TEST_KEYPAIR); @@ -164,7 +177,19 @@ async fn respond_from_nats_response() { nats = SETTINGS.clone().unwrap().nats.into(); } let sub = nats.subscribe("nova.cache.dispatch.interaction").unwrap(); - let ping = json!({ "type": 2, "id": "0", "application_id": "0", "token": "random token", "version": 1 }).to_string(); + let ping = json!({ + "type": 2, + "id": "0", + "application_id": "0", + "token": "random token", + "version": 1, + "channel_id": "123", + "data": { + "id": "0", + "name": "command" + } + }).to_string(); + let timestamp = "my datetime :)"; let signature_data = [timestamp.as_bytes().to_vec(), ping.as_bytes().to_vec()].concat(); let signature = sign_message(signature_data, &TEST_KEYPAIR); @@ -182,6 +207,7 @@ async fn respond_from_nats_response() { .header("X-Signature-Timestamp", timestamp) .body(Body::from(ping.clone())) .expect("request builder"); + let client = hyper::client::Client::new(); let result = client.request(req).await.unwrap(); assert_eq!(result.status(), StatusCode::OK); @@ -201,6 +227,7 @@ async fn response_400_when_invalid_json_body() { .header("X-Signature-Timestamp", timestamp) .body(Body::from(ping.clone())) .expect("request builder"); + let client = hyper::client::Client::new(); let result = client.request(req).await.unwrap(); assert_eq!(result.status(), StatusCode::BAD_REQUEST);