Skip to content

Commit 28cbb0c

Browse files
committed
Move IpAddr, SocketAddr and friends into core.
This is discussed in [RFC 2832], which is not accepted yet. There seems to be no significant objection to including `IpAddr` and friends. There is an objection to `SocketAddr` and friends: > If the socketaddr types aren't identical across platforms, I don't > think we want them in core. Here is a possible interpretation: core, and even the Rust language itself, already contains types with platform-specific layouts. For example, `u64` has a platform-dependent alignment, and that's visible even in otherwise fully encapsulating types like `core::time::Duration`. And core already has a `core::arch`, which is explicitly architecture-dependent. It seems the truly essential constraints of core are: - Nothing that does I/O. That goes in std. - No dynamic allocation. That goes in alloc. - No dependencies. - The public portable API feature set (eg. not `core::arch`) must be platform-independent. No unencapsulated `c_char` (signedness is platform-dependent) or `c_long` (range is platform-dependent). (Some types, like `c_schar`, could be debated, because one could argue that no serious platform would ever make `c_schar` different from `i8` ever again, but it isn't urgent to settle this.) - There must be fallback code so that core can be ported without any OS-specific work. So I propose the path is: add the socket types to core, with encapsulated OS-specific internal representations. The public-facing feature set will be platform-independent. And add a `core::os` module, similar to `core::arch` but for OS-specific features, which defines `Ext` extension traits, similar to `std::os::*`, which expose the platform-specific internal representations for FFI use cases. A platform with no `core::os` support will still be able to use `core` without any porting work, they just won't be able to access the internal representations, which isn't a regression. [RFC 2832]: rust-lang/rfcs#2832
1 parent de4b242 commit 28cbb0c

16 files changed

+3283
-0
lines changed

library/core/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
#![feature(const_int_unchecked_arith)]
117117
#![feature(const_intrinsic_copy)]
118118
#![feature(const_intrinsic_forget)]
119+
#![feature(const_ipv4)]
120+
#![feature(const_ipv6)]
119121
#![feature(const_likely)]
120122
#![feature(const_maybe_uninit_as_ptr)]
121123
#![feature(const_maybe_uninit_assume_init)]
@@ -132,6 +134,7 @@
132134
#![feature(const_size_of_val)]
133135
#![feature(const_slice_from_raw_parts)]
134136
#![feature(const_slice_ptr_len)]
137+
#![feature(const_socketaddr)]
135138
#![feature(const_str_from_utf8_unchecked_mut)]
136139
#![feature(const_swap)]
137140
#![feature(const_trait_impl)]
@@ -310,6 +313,7 @@ pub mod ffi;
310313
pub mod iter;
311314
#[unstable(feature = "once_cell", issue = "74465")]
312315
pub mod lazy;
316+
pub mod net;
313317
pub mod option;
314318
pub mod panic;
315319
pub mod panicking;

0 commit comments

Comments
 (0)