Skip to content

Commit

Permalink
Converts AddressFamily to struct with associated consts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan561 committed Nov 30, 2023
1 parent e13a182 commit 70175c4
Show file tree
Hide file tree
Showing 9 changed files with 572 additions and 371 deletions.
1 change: 1 addition & 0 deletions changelog/2210.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added more `AddressFamily` variants.
1 change: 1 addition & 0 deletions changelog/2210.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Converted `AddressFamily` to struct with associated constants to support vendor-defined address families.
2 changes: 1 addition & 1 deletion examples/getifaddrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
let family = addr
.address
.as_ref()
.and_then(SockaddrStorage::family)
.map(SockaddrStorage::family)
.map(|af| format!("{:?}", af))
.unwrap_or("".to_owned());
match (
Expand Down
5 changes: 2 additions & 3 deletions src/ifaddrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,10 @@ mod tests {
} else {
continue;
};
if sock.family() == Some(crate::sys::socket::AddressFamily::Inet) {
if sock.family() == crate::sys::socket::AddressFamily::INET {
let _ = sock.as_sockaddr_in().unwrap();
return;
} else if sock.family()
== Some(crate::sys::socket::AddressFamily::Inet6)
} else if sock.family() == crate::sys::socket::AddressFamily::INET6
{
let _ = sock.as_sockaddr_in6().unwrap();
return;
Expand Down
Loading

0 comments on commit 70175c4

Please sign in to comment.