checkpoint

This commit is contained in:
Jett Chen 2023-12-10 03:44:31 +08:00
parent 17610ff90d
commit 94233874e6
39 changed files with 490 additions and 336 deletions

View file

@ -25,7 +25,9 @@ impl Debug for TunInterface {
impl TunInterface {
#[throws]
pub fn new() -> TunInterface { Self::new_with_options(TunOptions::new())? }
pub fn new() -> TunInterface {
Self::new_with_options(TunOptions::new())?
}
#[throws]
pub(crate) fn new_with_options(options: TunOptions) -> TunInterface {
@ -37,17 +39,18 @@ impl TunInterface {
if handle.is_null() {
unsafe { GetLastError() }.ok()?
}
TunInterface {
handle,
name: name_owned,
}
TunInterface { handle, name: name_owned }
}
pub fn name(&self) -> String { self.name.clone() }
pub fn name(&self) -> String {
self.name.clone()
}
}
impl Drop for TunInterface {
fn drop(&mut self) { unsafe { sys::WINTUN.WintunCloseAdapter(self.handle) } }
fn drop(&mut self) {
unsafe { sys::WINTUN.WintunCloseAdapter(self.handle) }
}
}
pub(crate) mod sys {