Skip to content

Commit

Permalink
support ipv4/ipv6 -> host conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDC committed Sep 12, 2024
1 parent e7259cf commit 4e2e547
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rama-net/src/address/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ impl From<IpAddr> for Host {
}
}

impl From<Ipv4Addr> for Host {
fn from(ip: Ipv4Addr) -> Self {
Host::Address(IpAddr::V4(ip))
}
}

impl From<Ipv6Addr> for Host {
fn from(ip: Ipv6Addr) -> Self {
Host::Address(IpAddr::V6(ip))
}
}

impl fmt::Display for Host {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down

0 comments on commit 4e2e547

Please sign in to comment.