Repository navigation
Tracking issue for Ipv{4,6}Addr convenience methods #27709
Copy link
Copy link
Open
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-libs-radarLibs issues that are tracked on the team's radar.Libs issues that are tracked on the team's radar.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
The below is a list of methods left to be stabilized under the ip feature. The path forward today is unclear; if you'd like to push through any method on here the libs team is interested in a PR with links to the associated RFCs or other official documentation. Let us know!
-
Ipv4Addr::is_shared RemoveIpv4Addr::is_ietf_protocol_assignmentIpv4Addr::is_ietf_protocol_assignment#86439-
Ipv4Addr::is_benchmarking -
Ipv4Addr::is_reserved
-
Ipv6Addr::is_unicast_global -
Ipv6Addr::is_unicast_link_local RemoveIpv6Addr::is_unicast_link_local_strictIpv6Addr::is_unicast_link_local_strict#85819RemoveIpv6Addr::is_unicast_site_localIpv6Addr::is_unicast_site_local#85820-
Ipv6Addr::is_unique_local -
Ipv6Addr::multicast_scope
-
Ipv6Addr::is_ipv4_mapped -
Ipv6Addr::to_ipv4_mappedStabilizeIpv6Addr::to_ipv4_mapped#96906 -
Ipv6Addr::to_canonicalStabilize{IpAddr, Ipv6Addr}::to_canonical#115955 -
IpAddr::to_canonicalStabilize{IpAddr, Ipv6Addr}::to_canonical#115955
Steps
- Implementation std: Add a
netmodule for TCP/UDP #22015 - Implementation Add IpAddr common methods #34694
- Stabilization attempt stabilize the "ip" feature #66584
- Stabilization attempt Stabilize the "IP" feature #76098
- Stabilization PR(s)
Subsets of the listed methods can be stabilized, rather than attempting to stabilize everything at once.
Unresolved Questions
-
is_documentationis not up to dateIpv6Addr::is_documentationshould be expanded to include RFC 9637's3ffff::/20#137821 - Differences between Rust and other languages Stabilize the "IP" feature #76098 (comment)
- More specific case of the above: does the IPv6 unicast interface do what we expect? IPv6 Unicast Interface #85604
- Do the provided methods pass ipcheck? https://github.com/rust-lang/libs-team/tree/93b78eef2e0d455a3e69c05333cd8f276e4e95f1/tools/ipcheck. Last known run: Stabilize the "IP" feature #76098 (comment)
From @KodrAus in #76098 (comment):
- Should we replace the
Ipv6Addr::is_unicast_*methods with aIpv6Addr::unicast_scopemethod that returns aIpv6UnicastScopeenum (Stabilize the "IP" feature #76098 (comment))? - Should we change the behavior of
Ipv6Addr::to_ipv4to ignore deprecated IPv4-compatible addresses, or deprecate the whole method in favor of the more correctIpv6Addr::to_ipv4_mappedmethod (Stabilize the "IP" feature #76098 (comment))? - Are we ok with
Ipv6Addr::is_*methods now properly considering mapped (non-deprecated) IPv4 addresses? I'd personally be comfortable considering the old behavior a bug. - Are there any behavioral differences between other language implementations that we should investigate? (Stabilize the "IP" feature #76098 (comment))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCI-libs-radarLibs issues that are tracked on the team's radar.Libs issues that are tracked on the team's radar.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Activity
aturon commentedon Nov 3, 2015
I think we should consider this for stabilization in 1.6. Nominating.
alexcrichton commentedon Nov 5, 2015
🔔 This issue is now entering its cycle-long final comment period for stabilization 🔔
Concretely, we discussed this in the libs meeting and the conclusion was that the boolean accessors are likely ready for stabilization after verifying that they're all the canonical definitions, but the
enum-returning variants will likely remain unstable for now.briansmith commentedon Nov 5, 2015
What, exactly, is the "ip feature"? Could you link to the RustDoc(s) of the specific things that are supposed to be reviewed?
SimonSapin commentedon Nov 5, 2015
I think "ip feature" in this context refers to things annotated with
#![unstable(feature = "ip", …)], which require#![feature(ip)]to be used.briansmith commentedon Nov 6, 2015
I don't mean to be rude, but that's just a restating my question as the answer. if you want people to actually give feedback on the proposal, it should be easier to understand what the proposal is. In this case, it is pretty difficult to tell what is being proposed because the module mixes stable and unstable features.
I noticed that a large part of this module could work in
#![no_std]mode. I suggest moving the#![no_std]-compatible parts tocore::net, or at least consider how making it work with#![no_std]would affect the API.It also seems odd that
Ipv4AddrandIpv6Addrhave things likeis_multicastandis_globalbut there's no trait that allows code to make these queries generically over those types of addresses. If such a trait were to bad added later, would the existence of these non-trait methods cause problems? If so, it might be worth considering building the trait first.steveklabnik commentedon Nov 6, 2015
@briansmith I don't think that's being rude, there's just tension here between "we've been doing this a while so we're a bit short" and "newer people might not know what that is." @SimonSapin leaned a bit towards a literal explanation, but you're right to point out that more detail is good.
I read @alexcrichton 's comment as:
http://doc.rust-lang.org/std/net/struct.Ipv4Addr.html and http://doc.rust-lang.org/std/net/struct.Ipv6Addr.html <- all the stuff here that is
-> boolhttp://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.multicast_scope is the only one I see that's unstable.
huonw commentedon Nov 6, 2015
FWIW, I filed #29221 a while ago, which would make tracking down what these tracking issues refer to slightly easier.
alexcrichton commentedon Nov 6, 2015
Yes, to be concrete, I was proposing stabilizing:
Ipv4Addr::is_unspecifiedIpv4Addr::is_loopbackIpv4Addr::is_privateIpv4Addr::is_link_localIpv4Addr::is_globalIpv4Addr::is_multicastIpv4Addr::is_broadcastIpv4Addr::is_documentationIpv6Addr::is_unspecifiedIpv6Addr::is_loopbackIpv6Addr::is_globalIpv6Addr::is_unique_localIpv6Addr::is_unicast_link_localIpv6Addr::is_unicast_site_localIpv6Addr::is_unicast_globalIpv6Addr::is_multicastNote that this is all pending actually verifying that these are standard properties of the respective IP address space and are well known with canonical implementations. I believe they fit this requirement already but would like to double-check.
@briansmith
Yeah these things can certainly move around over time (it's backwards compatible to move them at a later date). I'd be a little wary of putting things in core "just because" without a concrete purpose, and these kinda fall into the category I'd be wary of. For example the internal representation of each of these primitives is the
libcequivalent (e.g.libc::sockaddr_in6orlibc::in_addr) which unfortunately isn't available in libcore, so if we move it to core we'd have to invent our own storage format.Method resolution favors inherent methods (methods defined on the type itself) over trait methods (e.g. impl'd traits plus the trait being in scope), so in that sense we're covered to add a trait at a future date. That being said the standard library doesn't have too many traits like this for abstracting between one or two types, so I would personally want to hold off on this extension for now.
A possible alternative, however, could be adding the common set of methods to
IpAddrif we end up stabilizing that as well.ollie27 commentedon Nov 9, 2015
A couple of issues I have noticed with what we have:
0.0.0.0/8,::and many more ranges shouldn't return true foris_global()Ipv6Addr::is_documentationis missing and should be2001:db8::/32On a more general note, might some of these functions need to be updated in the future if new ranges are assigned? How would that be handled?
132 remaining items
fgsch commentedon Sep 23, 2025
What's missing here to get this stabilised? Is just getting @alexcrichton to mark it as such?
Anything we can do to get this moving?
Changed is_valid_ipv4 to is_global_ipv4 and added a link to the block…
Rollup merge of rust-lang#154196 - Jules-Bertholet:ipv6-multicast-dis…
Unrolled build for #154196
fix(sharer): redact IPs in dbg_log, validate UPnP responses, document…
DenizUgur commentedon May 21, 2026
What needs to be done for this feature to be stabilized?
fix(core): classify TEST-NET-1 and broadcast as internal IPv4
fix(core): classify TEST-NET-1 and broadcast as internal IPv4
fix(core): classify TEST-NET-1 and broadcast as internal IPv4
fix(core): classify TEST-NET-1 and broadcast as internal IPv4
joshhansen commentedon Jul 20, 2026
Just chiming in that a stabilization of
IpAddr::is_global,Ipv4Addr::is_global, andIpv6Addr::is_globalwould fill an important gap for my project, particularly givenis_loopback,is_multicast, andis_unspecifiedare already present. Or if there is some particular difficulty to stabilizing, it would be helpful to get some word on what that is, in case we might help push it across the finish line. Thankstest+fix(native): adversarial coverage for the download engine and ne…
test+fix(native): adversarial coverage for the download engine and ne…