Dependencies:
[dependencies]
tokio-tungstenite = "0.12.0"
tokio = { version = "1", features = ["rt", "full"] }
Rust code:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = tokio_tungstenite::connect_async("ws://localhost:8080").await;
Ok(())
}
Output:
Compiling foo v0.1.0 (C:\Users\achin\tmp\19\foo)
Finished dev [unoptimized + debuginfo] target(s) in 1.74s
Running `target\debug\foo.exe`
thread 'main' panicked at 'requires the `rt` Tokio feature flag', C:\Users\achin\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-0.3.7\src\blocking.rs:18:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\foo.exe` (exit code: 101)