From b0b972966295e8e1273bd255cd5a5c94cc384f4b Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Mon, 13 Nov 2023 12:43:00 +0100 Subject: [PATCH] + ws_stream_wasm, - dev-dependency on tokio/full --- Cargo.lock | 106 +++++++++++++++++++++++++--------- Cargo.toml | 2 +- examples/gateway_observers.rs | 2 +- examples/gateway_simple.rs | 2 +- 4 files changed, 81 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99ff172..d820185 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,17 @@ dependencies = [ "syn 2.0.31", ] +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures", + "pharos", + "rustc_version", +] + [[package]] name = "atoi" version = "2.0.0" @@ -209,6 +220,7 @@ dependencies = [ "tokio", "tokio-tungstenite", "url", + "ws_stream_wasm", ] [[package]] @@ -533,6 +545,21 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1fd087255f739f4f1aeea69f11b72f8080e9c2e7645cd06955dad4a178a49e3" +[[package]] +name = "futures" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.28" @@ -606,6 +633,7 @@ version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", "futures-io", "futures-macro", @@ -730,12 +758,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - [[package]] name = "hex" version = "0.4.3" @@ -1175,16 +1197,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.32.1" @@ -1297,6 +1309,16 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures", + "rustc_version", +] + [[package]] name = "pin-project" version = "1.1.3" @@ -1603,6 +1625,15 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" version = "0.38.11" @@ -1725,6 +1756,18 @@ dependencies = [ "libc", ] +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.188" @@ -1841,15 +1884,6 @@ dependencies = [ "digest", ] -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - [[package]] name = "signature" version = "2.1.0" @@ -2286,10 +2320,7 @@ dependencies = [ "bytes", "libc", "mio", - "num_cpus", - "parking_lot", "pin-project-lite", - "signal-hook-registry", "socket2 0.5.3", "tokio-macros", "windows-sys", @@ -2780,6 +2811,25 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures", + "js-sys", + "log", + "pharos", + "rustc_version", + "send_wrapper", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 9df79d0..1919085 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,8 +56,8 @@ chorus-macros = "0.2.0" rustls = "0.21.8" rustls-native-certs = "0.6.3" rand = "0.8.5" +ws_stream_wasm = "0.7.4" [dev-dependencies] -tokio = { version = "1.32.0", features = ["full"] } lazy_static = "1.4.0" rusty-hook = "0.11.2" diff --git a/examples/gateway_observers.rs b/examples/gateway_observers.rs index 1572aa9..0a54d31 100644 --- a/examples/gateway_observers.rs +++ b/examples/gateway_observers.rs @@ -24,7 +24,7 @@ impl Observer for ExampleObserver { } } -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() { // Find the gateway websocket url of the server we want to connect to let websocket_url_spacebar = "wss://gateway.old.server.spacebar.chat/".to_string(); diff --git a/examples/gateway_simple.rs b/examples/gateway_simple.rs index 26e8416..276d95f 100644 --- a/examples/gateway_simple.rs +++ b/examples/gateway_simple.rs @@ -4,7 +4,7 @@ use chorus::{self, gateway::Gateway, types::GatewayIdentifyPayload}; use tokio::time::sleep; /// This example creates a simple gateway connection and a session with an Identify event -#[tokio::main] +#[tokio::main(flavor = "current_thread")] async fn main() { // Find the gateway websocket url of the server we want to connect to let websocket_url_spacebar = "wss://gateway.old.server.spacebar.chat/".to_string();