Tokio: Support Webassembly

Created on 25 Sep 2019  路  9Comments  路  Source: tokio-rs/tokio

Hey,
Please provide wasm support to this library. Networking is one of the important feature to work on Rust+WASM codes.
Not sure is there any tracker for this. Happy to contribute if any.

Thanks

A-tokio C-feature-request

Most helpful comment

tokio has the best sync primitive implementation, it would be great if it could be used on wasm.

Indeed tokio's non-networking primitives would be extremely useful in wasm in the browser: channels, mutexes, (single-threaded) runtime, etc.

All 9 comments

Sounds very interesting. Could you provide more context around what wasm platform you are targetting? As far as I know, in the browser, there are no TCP sockets. I'm not familiar w/ other wasm platforms.

@carllerche We need all the network protocols like rpc, tcp, websocket and I/O operations

I felt we should first focus on clang compiler as wasm32-unknown-unknown target is closely embedded with Rust. Its a Rust compiler backend for WebAssembly( without emscripten)

If anyone want to use any Http calls its depends on tokio, hyper, websocket libraries. so we need to make sure all the network protocols can be handled in Rust.
To do so the core is in tokio.rs so I came here for the support.

This is about WASI (https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/) I guess?

@AchalaSB Support of wasm would require someone to investigate wasm capability.
There are many possible variants when building for wasm, and stuff like tcp/udp is definitely not available on browser.

If you're familiar with wasm platforms, it would be good if you could elaborate on availability of IO primitives and event loops there

Is there a wasm platform today that supports TCP?

The wasm32-unknown-wasi target will in the future I believe, but it doesn't look like it does currently: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/wasi/net.rs

Tokio has the best sync primitive implementation, it would be great if it could be used on wasm.

tokio has the best sync primitive implementation, it would be great if it could be used on wasm.

Indeed tokio's non-networking primitives would be extremely useful in wasm in the browser: channels, mutexes, (single-threaded) runtime, etc.

tokio with feature flags sync and rt successfully compiles for wasm32-unknown-unknown.
I didn't test if it works though.

Was this page helpful?
0 / 5 - 0 ratings