Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I experimented with this some weeks ago and it is certainly possible.

I had a PoC where my server runs Rust, exposes a JSON Rest API using serde to serialize my Rust structs to JSON. On the web Client I compiled Rust to wasm and used the Reqwest crate (http client that uses Fetch in wasm) to talk to my server, Rust structs are shared between server and client.

For me, the beauty about Rust in this setup, is that cross compiling/crossplatform is builtin into the tooling (Cargo). For example the Reqwest crate compiles down to use the browser Fetch api when running in Wasm, and the same crate on the server uses a native implementation using openssl (or rusttls).



I did something making a game. The game logic runs server side however in order to hide latency the clients also run a WASM copy locally. Then once the server processes their moves they check that everything was in-sync and if not reload with the server state.

(In practice the validation is probably not necessary but doesn't hurt to have).


I even use druid for a simple browser gui on top of a rust json rest service. For an internal tool. Serde on both ends. Works great.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: