tokio-rs / tokio-core

I/O primitives and event loop for async I/O in Rust
Apache License 2.0
638 stars 115 forks source link

Build for wasm32-unknown-unknown #327

Open saschagrunert opened 6 years ago

saschagrunert commented 6 years ago

Hey there,

I want to use an RPC based technique like capnp-rpc for my client and server side web project. This lib relies on tokio-core, so my naive approach was to build it for the wasm32-unknown-unknown or wasm32-unknown-emscripten target to use it on the client side of the web app. Unfortunately the dependencies seem too tight for both compilers:

    ...
   Compiling num_cpus v1.8.0
error[E0432]: unresolved import `sys`
  --> /home/sascha/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/tcp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ Maybe a missing `extern crate sys;`?
error[E0432]: unresolved import `sys`
  --> /home/sascha/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/udp.rs:18:5
   |
18 | use sys::c;
   |     ^^^ Maybe a missing `extern crate sys;`?
error[E0432]: unresolved import `sys`
  --> /home/sascha/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/socket.rs:20:5
   |
20 | use sys;
   |     ^^^ no `sys` in the root
error[E0432]: unresolved import `sys`
  --> /home/sascha/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/socket.rs:21:5
   |
21 | use sys::c;
   |     ^^^ Maybe a missing `extern crate sys;`?
error[E0433]: failed to resolve. Maybe a missing `extern crate sys;`?
  --> /home/sascha/.cargo/registry/src/github.com-1ecc6299db9ec823/net2-0.2.32/src/socket.rs:34:13
   |
34 |         use sys::c::socklen_t as len_t;
   |             ^^^ Maybe a missing `extern crate sys;`?

Do you think it would be useful to use the tokio related libs within a web frontend context or is my initial approach not the best?