# What !? This crate provides a rust interface to the win32 function [GetAdaptersAddresses](https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses). # Why !? There is a [windows crate](https://crates.io/crates/windows). But the function [GetAdaptersAddresses](https://microsoft.github.io/windows-docs-rs/doc/windows/Win32/NetworkManagement/IpHelper/fn.GetAdaptersAddresses.html) is not fun to use. * The user is expected to manage memory for the output with HeapAlloc/HeapFree. * The user is expected to traverse the linked-list of adapters and addresses. * The user is expected to cast the *SOCKADDR to *SOCKADDR_IN / *SOCKADDR_IN6 to interpret it. * its all unsafe. # How does this work then!? The struct `AdaptersAddresses` allocates and owns the buffer that GetAdaptersAddresses() wrote to. Iterating over this produces `Adapter`'s. Adapters are queries for their various attributes, often iterable. # Example ! ```rs use get_adapters_addresses::*; fn main() -> Result<()> { let adapter_addresses = AdaptersAddresses::try_new(Family::Unspec, *Flags::default().include_gateways())?; for adapter in &adapter_addresses { println!("============================================================"); println!("adapter name: {:?}", adapter.adapter_name()); println!("friendly name: {:?}", adapter.friendly_name()); println!("description: {:?}", adapter.description()); println!("interface_type {:?}", adapter.interface_type()); if let Some(physical_address) = adapter.physical_address() { println!( "physical_address: {} {{{:X}}}", physical_address, physical_address.as_u64() ); } println!("status: {:?}", adapter.operational_status()); for addr in adapter.unicast_addresses() { println!("\tunicast: {:?}", addr); } for addr in adapter.multicast_addresses() { println!("\tmulticast: {:?}", addr); } for addr in adapter.anycast_addresses() { println!("\tanycast: {:?}", addr); } for addr in adapter.dns_addresses() { println!("\tdns: {:?}", addr); } for addr in adapter.gateway_addresses() { println!("\tgateway: {:?}", addr); } println!("\tdhcpv4: {:?}", adapter.dhcpv4_address()); println!("\tdhcpv6: {:?}", adapter.dhcpv6_address()); } Ok(()) } ```