This crate provides a rust interface to the win32 function GetAdaptersAddresses.
There is a windows crate. But the function GetAdaptersAddresses is not fun to use.
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.
```rs use getadaptersaddresses::*; fn main() -> Result<()> { let adapteraddresses = AdaptersAddresses::trynew(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(())
} ```