Code Monkey home page Code Monkey logo

Comments (6)

debris avatar debris commented on June 25, 2024

yes, but I'm afraid it won't work for network requests, cause io::Read, io::Write may return WouldBlock error

What we need is serde using futures internally

from jsonrpc.

tomusdrw avatar tomusdrw commented on June 25, 2024

I think it would be possible to create a buffered reader that addresses this issue. You just need to make sure that BufferedReader polling occurs in the event loop, and serde_json::from_reader is blocking some other thread.
Although it indeed seems a bit complicated.

from jsonrpc.

mmacedoeu avatar mmacedoeu commented on June 25, 2024

Hey guys maybe you need tokio_io::{AsyncRead, AsyncWrite}
https://github.com/tokio-rs/tokio-io/blob/master/src/lib.rs#L94
https://github.com/hyperium/hyper/blob/master/src/server/mod.rs#L270

from jsonrpc.

NikVolf avatar NikVolf commented on June 25, 2024

@mmacedoeu yep but serde does not use it
and if it were, it would have to return futures instead of instant result on such (de)serialization requests

from jsonrpc.

mmacedoeu avatar mmacedoeu commented on June 25, 2024

Now I see :)
Maybe some could wrap serde into a CpuFuture:
https://github.com/alexcrichton/futures-rs/blob/master/futures-cpupool/src/lib.rs#L114

or try FramedRead, FramedWrite:
https://github.com/carllerche/tokio-serde/blob/master/src/lib.rs#L223

for json:
https://github.com/carllerche/tokio-serde-json/blob/master/examples/server.rs

from jsonrpc.

tomusdrw avatar tomusdrw commented on June 25, 2024

Closing since it seems unrealistic.

from jsonrpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.