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 29, 2023
1 parent 39ad47b commit 3ae5caf
Show file tree
Hide file tree
Showing 10 changed files with 547 additions and 374 deletions.
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ fn main() {
dragonfly: { target_os = "dragonfly" },
ios: { target_os = "ios" },
freebsd: { target_os = "freebsd" },
fuchsia: { target_os = "fuchsia" },
haiku: { target_os = "haiku" },
illumos: { target_os = "illumos" },
linux: { target_os = "linux" },
macos: { target_os = "macos" },
netbsd: { target_os = "netbsd" },
openbsd: { target_os = "openbsd" },
redox: { target_os = "redox" },
solaris: { target_os = "solaris" },
watchos: { target_os = "watchos" },
tvos: { target_os = "tvos" },
Expand Down
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 3ae5caf

Please sign in to comment.