当我运行 dioxus 项目并添加 tokio 依赖时
tokio = { version = "1.37.0", features = ["full"] }
会显示
error[E0599]: no method named `deregister` found for struct `IoSource<std::net::UdpSocket>` in the current scope
--> /Users/xy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/net/udp.rs:635:20
|
635 | self.inner.deregister(registry)
| ^^^^^^^^^^ method not found in `IoSource<UdpSocket>`
|
::: /Users/xy/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.11/src/io_source.rs:62:1
|
62 | pub struct IoSource<T> {
| ---------------------- method `deregister` not found for this struct
Some errors have detailed explanations: E0412, E0425, E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `mio` (lib) due to 44 previous errors
我尝试了
cargo clean
和cargo update
,但没有成功
这与 Dioxus #1330 有关,总而言之,tokio 与 WebAssembly 不能很好地配合。它们的不兼容性也在here进行了讨论,并且根据 Tokio #1597,他们没有计划让 tokio 与 WASM 一起工作。