-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
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 RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
Feature gate: #![feature(ip_bits)]
This is a tracking issue for IpvNAddr::{BITS, to_bits, from_bits}
.
This API exists mostly so that users can be explicit about various bit operations which are useful for computing IP networks (see ACP linked below). For example, IpvNAddr::BITS - ip.to_bits().trailing_zeros()
can be used to determine the network prefix length of a given address.
Additionally, since const
traits are still a long ways out, this provides a const
version of the conversions to/from integers that people can use in the meantime.
Public API
impl Ipv4Addr {
pub const BITS: u32 = 32;
pub const fn from_bits(bits: u32) -> Ipv4Addr;
pub const fn to_bits(self) -> u32;
}
impl Ipv6Addr {
pub const BITS: u32 = 128;
pub const fn from_bits(bits: u128) -> Ipv4Addr;
pub const fn to_bits(self) -> u128;
}
Steps / History
- API change proposal (ACP)1: ACP: Extended logic for IP networks libs-team#235
- Implementation: Add BITS, from_bits, to_bits to IP addresses #113746
- Improve docs regarding endianness: Elaborate on ip_addr bit conversion endianness #118505
- Final comment period (FCP)2
- Stabilization PR: Stabilise
IpvNAddr::{BITS, to_bits, from_bits}
(ip_bits
) #125551
Unresolved Questions
- None yet.
Footnotes
puetzpkellerkindt, GoldsteinE and yungcomputerchair
Metadata
Metadata
Assignees
Labels
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 RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.