mio::event::Source

This commit is contained in:
ssrlive 2023-09-19 12:55:02 +08:00
parent 8aeaf238f2
commit 3e7a4dc8b2
4 changed files with 32 additions and 2 deletions

View file

@ -1,3 +1,4 @@
use mio::{event, Interest, Registry, Token};
use smoltcp::{
phy::{self, Device, DeviceCapabilities, Medium},
time::Instant,
@ -22,6 +23,20 @@ pub struct WinTunInterface {
// }
// }
impl event::Source for WinTunInterface {
fn register(&mut self, _registry: &Registry, _token: Token, _interests: Interest) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "register"))
}
fn reregister(&mut self, _registry: &Registry, _token: Token, _interests: Interest) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "reregister"))
}
fn deregister(&mut self, _registry: &Registry) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "deregister"))
}
}
impl WinTunInterface {
pub fn new(name: &str, medium: Medium) -> io::Result<WinTunInterface> {
let wintun = unsafe { wintun::load() }.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;