Comments (3)
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.
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.
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)
- Framed send fails with "Socket operation on non-socket" HOT 3
- Drop Fd crash in Android 11 HOT 1
- Nothing happening on macOS HOT 2
- Use library with default gateway
- Could you elaborate on what routing needs to be done for MacOs? HOT 14
- Where is the tun tap frame? HOT 1
- Build error on windows HOT 1
- GRO/GSO on Linux HOT 1
- macOS tun ip cannot be listened by the application
- The synchronous `write` does not work HOT 1
- when change ip addr to new ip addr, but subnet broadcast address no change, in macos m1 HOT 1
- Windows support can be achieved in this fork
- Add serde pls HOT 1
- Help with multithreading, read and write. HOT 2
- Add support to construct `TunPacket` from `Bytes` directly. HOT 1
- Enable TCP Segmentation Offload (TSO)
- Memory leak on windows HOT 11
- add split api?
- ioctl is marked as "deprecated", should be replaced with nix HOT 1
- Project co-author recruitment HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-tun.