Feature gate: #![feature(ip_as_octets)]
This is a tracking issue for enabling reference access to IpAddr, Ipv4Addr, and Ipv6Addr contents. Previously, only an array copy was exposed via .octets().
Public API
impl core::net::IpAddr {
pub const fn as_octets(&self) -> &[u8];
}
impl core::net::Ipv4Addr {
pub const fn as_octets(&self) -> &[u8; 4];
}
impl core::net::Ipv6Addr {
pub const fn as_octets(&self) -> &[u8; 16];
}
Steps / History
Unresolved Questions
- @tgross35 offered a potential alternative in the ACP: that we instead provide
#[repr(transparent)] for these types and document layout stability, leaving transmutation to a byte slice to third-party libraries.
Feature gate:
#![feature(ip_as_octets)]This is a tracking issue for enabling reference access to
IpAddr,Ipv4Addr, andIpv6Addrcontents. Previously, only an array copy was exposed via.octets().Public API
Steps / History
core::net::Ip*Addroctet bytes,impl AsRef<[u8]> for core::net::Ip*Addrlibs-team#535IpAddr::as_octets()#136609Unresolved Questions
#[repr(transparent)]for these types and document layout stability, leaving transmutation to a byte slice to third-party libraries.