4
4
//! of interfaces and their associated addresses.
5
5
6
6
use std:: ffi;
7
+ use std:: fmt;
7
8
use std:: iter:: Iterator ;
8
9
use std:: mem;
9
10
use std:: option:: Option ;
@@ -15,6 +16,7 @@ use sys::socket::SockAddr;
15
16
use net:: if_:: * ;
16
17
17
18
/// Describes a single address for an interface as returned by `getifaddrs`.
19
+ #[ derive( Clone , Eq , Hash , PartialEq ) ]
18
20
pub struct InterfaceAddress {
19
21
/// Name of the network interface
20
22
pub interface_name : String ,
@@ -30,6 +32,12 @@ pub struct InterfaceAddress {
30
32
pub destination : Option < SockAddr > ,
31
33
}
32
34
35
+ impl fmt:: Debug for InterfaceAddress {
36
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
37
+ write ! ( f, "InterfaceAddress ({:?})" , self . interface_name)
38
+ }
39
+ }
40
+
33
41
cfg_if ! {
34
42
if #[ cfg( any( target_os = "emscripten" , target_os = "fuchsia" , target_os="linux" ) ) ] {
35
43
fn get_ifu_from_sockaddr( info: & libc:: ifaddrs) -> * const libc:: sockaddr {
@@ -73,6 +81,7 @@ impl InterfaceAddress {
73
81
/// Use the function `getifaddrs` to create this Iterator. Note that the
74
82
/// actual list of interfaces can be iterated once and will be freed as
75
83
/// soon as the Iterator goes out of scope.
84
+ #[ derive( Debug , Eq , Hash , PartialEq ) ]
76
85
pub struct InterfaceAddressIterator {
77
86
base : * mut libc:: ifaddrs ,
78
87
next : * mut libc:: ifaddrs ,
0 commit comments