Add Read and Write for Async TunInterface
Those features are implemented using AsyncFD. While write doesn't require a mutable reference to self, read does. Make Async Tun a feature remove async tun from workspace rename write/read to send/recv
This commit is contained in:
parent
d3882bd008
commit
beae8c0f79
12 changed files with 135 additions and 64 deletions
|
|
@ -166,17 +166,11 @@ impl TunInterface {
|
|||
let socket = Socket::new(Domain::IPV6, Type::DGRAM, None)?;
|
||||
perform(socket.as_raw_fd())?
|
||||
}
|
||||
}
|
||||
|
||||
impl Write for TunInterface {
|
||||
#[throws]
|
||||
fn write(&mut self, buf: &[u8]) -> usize {
|
||||
pub fn send(&self, buf: &[u8]) -> usize {
|
||||
self.socket.send(buf)?
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue