Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why local_ip() return IpAddr? #137

Open
amateomi opened this issue Mar 3, 2024 · 1 comment
Open

Why local_ip() return IpAddr? #137

amateomi opened this issue Mar 3, 2024 · 1 comment

Comments

@amateomi
Copy link

amateomi commented Mar 3, 2024

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.

@EstebanBorai
Copy link
Owner

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.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants