wire: add From<Address> for ::std::net::IpAddr

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
master
Marc-André Lureau 2019-05-16 16:34:32 +02:00 committed by Dario Nieuwenhuis
parent d0928cf068
commit aa10b5250a
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 {