local-ip-address
local-ip-address copied to clipboard
Why local_ip() return IpAddr?
According to documentation, local_ip()
function retrieves the local IPv4 address (and local_ipv6()
retrieves the local IPv6 address), but why inside return type is general IpAddr
enum instead of Ipv4Addr
and Ipv6Addr
? I think it's confusing and inconvenient for user.
According to documentation,
local_ip()
function retrieves the local IPv4 address (andlocal_ipv6()
retrieves the local IPv6 address), but why inside return type is generalIpAddr
enum instead ofIpv4Addr
andIpv6Addr
? I think it's confusing and inconvenient for user.
Hi @amateomi! Thanks for openning this issue!
This is because at first, only IPv4 Addresses were used. Then, with changes and contributions the need of a specific IP version came up.
It it was for me today, I would introduce these funcions as follows:
-
local_ip() -> IpAddr
-
local_ipv4() -> Ipv4Addr
-
local_ipv6() -> Ipv6Addr
If we want to go this way, we would have to revisit each OS impl and also draft a major release (thus dropping backwards).