X-Git-Url: https://code.octet-stream.net/netwatcher/blobdiff_plain/1c34fe3947aaf8af2d773d59bdebf19e17d78527..cc3e849e9ff8568609f160d4bcdb83966ffdb6c5:/src/list_win.rs?ds=sidebyside diff --git a/src/list_win.rs b/src/list_win.rs index e842244..718f2bb 100644 --- a/src/list_win.rs +++ b/src/list_win.rs @@ -16,9 +16,9 @@ use windows::Win32::Networking::WinSock::{ AF_INET, AF_INET6, AF_UNSPEC, SOCKADDR, SOCKADDR_IN, SOCKADDR_IN6, }; -use crate::{Error, IfIndex, Interface}; +use crate::{Error, Interface, List}; -pub fn list_interfaces() -> Result, Error> { +pub(crate) fn list_interfaces() -> Result { let mut ifs = HashMap::new(); // Microsoft recommends a 15 KB initial buffer let start_size = 15 * 1024; @@ -44,7 +44,7 @@ pub fn list_interfaces() -> Result, Error> { } ERROR_INVALID_PARAMETER => return Err(Error::Internal), ERROR_NOT_ENOUGH_MEMORY => return Err(Error::Internal), - ERROR_NO_DATA => return Ok(HashMap::new()), // there aren't any + ERROR_NO_DATA => return Ok(List(HashMap::new())), // there aren't any _ => return Err(Error::Internal), // TODO: Use FormatMessage to get a string } } @@ -98,7 +98,7 @@ pub fn list_interfaces() -> Result, Error> { } } - Ok(ifs) + Ok(List(ifs)) } #[cfg(test)] @@ -107,7 +107,7 @@ mod test { #[test] fn list() { - let ifaces = list_interfaces().unwrap(); + let ifaces = list_interfaces().unwrap().0; println!("{:?}", ifaces); } }