meh / rust-tun

TUN device creation and handling.
340 stars 133 forks source link

Add support to construct `TunPacket` from `Bytes` directly. #81

Open yiransheng opened 7 months ago

yiransheng commented 7 months ago

Code pointer: https://github.com/meh/rust-tun/blob/e762c419d71438e67379f9b2fed89b5cb835cc6a/src/async/codec.rs#L77C1-L80C2

TunPacket already stores the packet internally using bytes::Bytes, but it can only be constructed from a Vec via TunPacket::new. It would be nice to have a way (either a method of a From trait impl) to construct a TunPacket from Bytes directly, without going through the extra cloning in Bytes -> Vec -> Bytes.

xmh0511 commented 6 months ago

Fixed by https://github.com/ssrlive/rust-tun/pull/5, you can switch to tun2, which is actively maintaining.