Giter Site home page Giter Site logo

Tokio support about rust-tun HOT 3 CLOSED

meh avatar meh commented on July 4, 2024
Tokio support

from rust-tun.

Comments (3)

meh avatar meh commented on July 4, 2024

That's currently provided through mio, each Device implements mio::Evented which allows it to be used from tokio without doing anything tokio only.

What would be the difference with implementing tokio::Sink and tokio::Stream directly?

from rust-tun.

vorner avatar vorner commented on July 4, 2024

I might be missing something, but last time I looked at how Evented is used in tokio with PollEvented, it required quite a large amount of boilerplate code. So, the difference would be putting this boilerplate code into the crate itself so it can be reused, possibly behind a feature gate.

As a slightly related side note, when I discussed my code on the tokio gitter, I was told the Read and Write (and, in context of tokio, AsyncRead and AsyncWrite) traits aren't the best ones, because they assume the underlying object is stream of bytes, not bunch of discrete messages ‒ things like Write::write_all or Read::bytes make no sense in context of a TUN device that returns packets.

In that sense, having a Stream of packets seems like more natural API for that than AsyncRead provided by PollEvented. But having a recv method which returns a future, or a framed method, that takes a Codec and produces a stream of some messages, would make sense too.

from rust-tun.

meh avatar meh commented on July 4, 2024

That's a good point, I'd be fine with a feature-gated tokio implementation alongside the mio one.

from rust-tun.

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.