I would like to compile the following code with cargo-wasi.
// reqwest = { version = "0.11", features = ["json"] }
// tokio = { version = "1", features = ["full"] }
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::get("https://httpbin.org/ip")
.await?
.json::<HashMap<String, String>>()
.await?;
println!("{:#?}", resp);
Ok(())
}
After trying to compile it, I got the following error because mio doesn't currently support WASI
$ cargo wasi run
Compiling mio v0.7.9
Compiling parking_lot v0.11.1
Compiling serde_json v1.0.64
Compiling idna v0.2.2
error[E0432]: unresolved import `crate::sys::IoSourceState`
--> /home/ducaale/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.9/src/io_source.rs:12:5
|
12 | use crate::sys::IoSourceState;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ no `IoSourceState` in `sys`
... errors omitted
I did some research and none of the examples I found so far were utilizing async/await. Is there something I could replace tokio
with so my code compiles in WASI?