549: wire: add From<Address> for ::std::net::IpAddr r=Dirbaio a=Dirbaio

Originally from #296 

Co-authored-by: Marc-André Lureau <marcandre.lureau@redhat.com>
master
bors[bot] 2021-10-19 00:49:10 +00:00 committed by GitHub
commit 03492be337
1 changed files with 13 additions and 0 deletions

View File

@ -214,6 +214,19 @@ impl From<::std::net::IpAddr> for Address {
}
}
#[cfg(feature = "std")]
impl From<Address> for ::std::net::IpAddr {
fn from(x: Address) -> ::std::net::IpAddr {
match x {
#[cfg(feature = "proto-ipv4")]
Address::Ipv4(ipv4) => ::std::net::IpAddr::V4(ipv4.into()),
#[cfg(feature = "proto-ipv6")]
Address::Ipv6(ipv6) => ::std::net::IpAddr::V6(ipv6.into()),
_ => unreachable!(),
}
}
}
#[cfg(all(feature = "std", feature = "proto-ipv4"))]
impl From<::std::net::Ipv4Addr> for Address {
fn from(ipv4: ::std::net::Ipv4Addr) -> Address {