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

Add convenience method for handling ipv4-mapped addresses by canonicalizing them #87708

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

the8472
Copy link
Member

@the8472 the8472 commented Aug 2, 2021

This simplifies checking common properties in an address-family-agnostic
way since #86335 commits to not checking IPv4 semantics
of IPv4-mapped addresses in the Ipv6Addr property methods.

…them

This simplifies checking common properties in an address-family-agnostic
way since since rust-lang#86335 commits to not checking IPv4 semantics
of IPv4-mapped addresses in the `Ipv6Addr` property methods.
@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 2, 2021
@the8472 the8472 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 2, 2021
@the8472 the8472 changed the title Add convenience for handling ipv4-mapped addresses by canonicalizing them Add convenience method for handling ipv4-mapped addresses by canonicalizing them Aug 2, 2021
Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@dtolnay
Copy link
Member

dtolnay commented Aug 2, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Aug 2, 2021

📌 Commit a5cdff3 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 2, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 3, 2021
Add convenience method for handling ipv4-mapped addresses by canonicalizing them

This simplifies checking common properties in an address-family-agnostic
way since rust-lang#86335 commits to not checking IPv4 semantics
of IPv4-mapped addresses in the `Ipv6Addr` property methods.
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 3, 2021
Add convenience method for handling ipv4-mapped addresses by canonicalizing them

This simplifies checking common properties in an address-family-agnostic
way since rust-lang#86335 commits to not checking IPv4 semantics
of IPv4-mapped addresses in the `Ipv6Addr` property methods.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 3, 2021
Rollup of 8 pull requests

Successful merges:

 - rust-lang#87645 (Properly find owner of closure in THIR unsafeck)
 - rust-lang#87646 (Fix a parser ICE on invalid `fn` body)
 - rust-lang#87652 (Validate that naked functions are never inlined)
 - rust-lang#87685 (Write docs for SyncOnceCell From and Default impl)
 - rust-lang#87693 (Add `aarch64-apple-ios-sim` as a possible target to the manifest)
 - rust-lang#87708 (Add convenience method for handling ipv4-mapped addresses by canonicalizing them)
 - rust-lang#87711 (Correct typo)
 - rust-lang#87716 (Allow generic SIMD array element type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 423a930 into rust-lang:master Aug 3, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 3, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 15, 2023
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor `@the8472`

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 16, 2023
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2023
Rollup merge of rust-lang#115955 - tgross35:ip-to-canonical, r=dtolnay

Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
jstasiak added a commit to netaddr/netaddr that referenced this pull request Dec 15, 2023
This is one of the pieces missing to have a good IPv4-mapped IPv6
address handling story.

Following Rust's IpAddr::to_canonical() design[1][2][3] which seems
sensible to me (except that ours is simpler as we don't have separate
types for IPv4 and IPv6 addresses – yet).

Also, relying on doctests[4] to test this feature – no need to make things
more difficult than they need to be.

[1] https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.to_canonical
[2] https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.to_canonical
[3] rust-lang/rust#87708
[4] 3290b50 ("Make pytest run doctests (#280)")
jstasiak added a commit to netaddr/netaddr that referenced this pull request Dec 15, 2023
This is one of the pieces missing to have a good IPv4-mapped IPv6
address handling story.

Following Rust's IpAddr::to_canonical() design[1][2][3] which seems
sensible to me (except that ours is simpler as we don't have separate
types for IPv4 and IPv6 addresses – yet).

Also, relying on doctests[4] to test this feature – no need to make things
more difficult than they need to be.

[1] https://doc.rust-lang.org/std/net/enum.IpAddr.html#method.to_canonical
[2] https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.to_canonical
[3] rust-lang/rust#87708
[4] 3290b50 ("Make pytest run doctests (#280)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants