@@ -24,7 +24,7 @@ pub struct Interface {
2424 /// The address details of the interface.
2525 pub addr : IfAddr ,
2626 /// The index of the interface.
27- pub idx : Option < u32 > ,
27+ pub index : Option < u32 > ,
2828}
2929
3030impl Interface {
@@ -192,19 +192,19 @@ mod getifaddrs_posix {
192192 let name = unsafe { CStr :: from_ptr ( ifaddr. ifa_name ) }
193193 . to_string_lossy ( )
194194 . into_owned ( ) ;
195- let idx = {
196- let idx = unsafe { if_nametoindex ( ifaddr. ifa_name ) } ;
195+ let index = {
196+ let index = unsafe { if_nametoindex ( ifaddr. ifa_name ) } ;
197197
198198 // From `man if_nametoindex 3`:
199199 // The if_nametoindex() function maps the interface name specified in ifname to its
200200 // corresponding index. If the specified interface does not exist, it returns 0.
201- if idx == 0 {
201+ if index == 0 {
202202 None
203203 } else {
204- Some ( idx )
204+ Some ( index )
205205 }
206206 } ;
207- ret. push ( Interface { name, addr, idx } ) ;
207+ ret. push ( Interface { name, addr, index } ) ;
208208 }
209209
210210 Ok ( ret)
@@ -340,7 +340,7 @@ mod getifaddrs_windows {
340340 ret. push ( Interface {
341341 name : ifaddr. name ( ) ,
342342 addr,
343- idx : ifaddr. index ( ) ,
343+ index : ifaddr. index ( ) ,
344344 } ) ;
345345 }
346346 }
@@ -454,7 +454,7 @@ mod tests {
454454 ) ;
455455 // if index is set, it is non-zero
456456 for interface in & ifaces {
457- if let Some ( idx) = interface. idx {
457+ if let Some ( idx) = interface. index {
458458 assert ! ( idx > 0 ) ;
459459 }
460460 }
@@ -476,7 +476,7 @@ mod tests {
476476 }
477477
478478 #[ cfg( not( windows) ) ]
479- assert ! ( interface. idx . is_some( ) ) ;
479+ assert ! ( interface. index . is_some( ) ) ;
480480 }
481481 assert ! ( listed) ;
482482 }
0 commit comments