Make the IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, Ipv6MulticastScope and AddrParseError types available in no_std contexts by moving them into a core::net module.


The motivation here is to provide common types for both no_std and std targets which in turn will ease the creation of libraries based around IP addresses. Embedded IoT development is one area where this will be beneficial. IP addresses are portable across all platforms and have no external dependencies which is in line with the definition of the core library.

Guide-level explanation

The core::net::IpAddr, core::net::Ipv4Addr, core::net::Ipv6Addr, core::net::SocketAddr, core::net::SocketAddrV4, core::net::SocketAddrV6, core::net::Ipv6MulticastScope and core::net::AddrParseError types are available in no_std contexts.

Library developers should use core::net to implement abstractions in order for them to work in no_std contexts as well.

Reference-level explanation

Since has been merged, IP and socket address types are implemented in ideal Rust layout instead of wrapping their corresponding libc representation.

Formatting for these types has also been adjusted in and in order to remove the dependency on std::io::Write.

This means the types are now platform-agnostic, allowing them to be moved from std::net into core::net.


Moving the std::net types to core::net makes the core library less minimal.

Rationale and alternatives

  • Eliminates the need to use different abstractions for no_std and std.

  • Alternatively, move these types into a library other than core, so they can be used without std, and re-export them in std.

Prior art

There was a prior discussion at

and an experimental branch from @Nemo157 at

Unresolved questions


Future possibilities

Move the ToSocketAddrs trait to core::net as well. This depends on having core::io::Result.