]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=joshtriplett
authorMatthias Krüger <matthias.krueger@famsik.de>
Mon, 14 Nov 2022 18:26:14 +0000 (19:26 +0100)
committerGitHub <noreply@github.com>
Mon, 14 Nov 2022 18:26:14 +0000 (19:26 +0100)
commit9f3786b2b1f3450c796041175f08a7cae7da42f3
treef84a7c374e4a5f0bfd13441f7a670aae89ac4556
parent96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef
parent8f1e6eba343452ac48412f11d57aa7d206c8c3dd
Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=joshtriplett

Move `unix_socket_abstract` feature API to `SocketAddrExt`.

The pre-stabilized API for abstract socket addresses exposes methods on `SocketAddr` that are only enabled for `cfg(any(target_os = "android", target_os = "linux"))`. Per discussion in <https://github.com/rust-lang/rust/issues/85410>, moving these methods to an OS-specific extension trait is required before stabilization can be considered.

This PR makes four changes:
1. The internal module `std::os::net` contains logic for the unstable feature `tcp_quickack` (https://github.com/rust-lang/rust/issues/96256). I moved that code into `linux_ext/tcp.rs` and tried to adjust the module tree so it could accommodate a second unstable feature there.
2. Moves the public API out of `impl SocketAddr`, into `impl SocketAddrExt for SocketAddr` (the headline change).
3. The existing function names and docs for `unix_socket_abstract` refer to addresses as being created from abstract namespaces, but a more accurate description is that they create sockets in *the* abstract namespace. I adjusted the function signatures correspondingly and tried to update the docs to be clearer.
4. I also tweaked `from_abstract_name` so it takes an `AsRef<[u8]>` instead of `&[u8]`, allowing `b""` literals to be passed directly.

Issues:
1. The public module `std::os::linux::net` is marked as part of `tcp_quickack`. I couldn't figure out how to mark a module as being part of two unstable features, so I just left the existing attributes in place. My hope is that this will be fixed as a side-effect of stabilizing either feature.