-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make library compile for wasm32-wasi #122
Comments
I figured it out. I was able to used the latest jsonrpc-core. jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc" } This works from wasi too. use jsonrpc_core::{IoHandler, Params, Value};
use std::{io, io::prelude::*};
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
pub fn main() -> Result<()> {
let mut handler = IoHandler::new();
handler.add_sync_method("say_hello", |_: Params| Ok(Value::String("Hello World!".to_owned())));
for req in io::stdin().lock().lines() {
if let Some(rsp) = handler.handle_request_sync(&req?) {
println!("{}", rsp);
}
}
Ok(())
} |
This is blocked on async-rs/async-std#505 and tokio-rs/tokio#1597 unless someone has any clever ideas on how to replace the current runtimes. |
Given that I think the above is still true, and it's not a priority for us internally, I'll close this, but if anybody comes across this and is keen to have a play and finds a way to make it work, I'd be interested to know more! |
It would be great to be able to build a JSON-RPC 2.0 server that targets wasm32-wasi. The use case I'd like to support is the same as https://github.com/paritytech/jsonrpc/tree/master/stdio where the transport is stdio.
Today, if you try to
cargo build --target=wasm32-wasi
this project,socket2
fails to build. It would be nice to make that an optional dependency that is not included when a wasm32-wasi target.I first looked at https://paritytech.github.io/jsonrpc/jsonrpc_core/index.html, but it is still
using futures 0.1
. paritytech/jsonrpc#485 mentioned having a look at this project instead. It would be nice if the transport agnostic "core" was still possible.It is okay if this feature does not match this project's roadmap. I'm just trying to find out what can be reused and where collaborations can be made. Due to chemotherapy, my personal time investment may be low over the next three months. I'm hoping I can spark some ideas for others.
The text was updated successfully, but these errors were encountered: