Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=joshtriplett

Stabilise `unix_socket_abstract`

Fixes https://github.com/rust-lang/rust/issues/85410
This commit is contained in:
Matthias Krüger 2023-03-18 12:04:24 +01:00 committed by GitHub
commit 49a152885d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 20 deletions

View file

@ -1,8 +1,8 @@
//! Android-specific networking functionality.
#![unstable(feature = "tcp_quickack", issue = "96256")]
#![stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "tcp_quickack", issue = "96256")]

View file

@ -1,8 +1,8 @@
//! Linux-specific networking functionality.
#![unstable(feature = "tcp_quickack", issue = "96256")]
#![stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "tcp_quickack", issue = "96256")]

View file

@ -4,7 +4,7 @@ use crate::os::unix::net::SocketAddr;
use crate::sealed::Sealed;
/// Platform-specific extensions to [`SocketAddr`].
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub trait SocketAddrExt: Sealed {
/// Creates a Unix socket address in the abstract namespace.
///
@ -22,7 +22,6 @@ pub trait SocketAddrExt: Sealed {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixListener, SocketAddr};
/// use std::os::linux::net::SocketAddrExt;
///
@ -38,6 +37,7 @@ pub trait SocketAddrExt: Sealed {
/// Ok(())
/// }
/// ```
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
fn from_abstract_name<N>(name: N) -> crate::io::Result<SocketAddr>
where
N: AsRef<[u8]>;
@ -47,7 +47,6 @@ pub trait SocketAddrExt: Sealed {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixListener, SocketAddr};
/// use std::os::linux::net::SocketAddrExt;
///
@ -60,5 +59,6 @@ pub trait SocketAddrExt: Sealed {
/// Ok(())
/// }
/// ```
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
fn as_abstract_name(&self) -> Option<&[u8]>;
}

View file

@ -2,7 +2,7 @@
#![doc(cfg(any(target_os = "linux", target_os = "android")))]
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub(crate) mod addr;
#[unstable(feature = "tcp_quickack", issue = "96256")]

View file

@ -245,12 +245,12 @@ impl SocketAddr {
}
}
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
impl Sealed for SocketAddr {}
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
impl linux_ext::addr::SocketAddrExt for SocketAddr {
fn as_abstract_name(&self) -> Option<&[u8]> {
if let AddressKind::Abstract(name) = self.address() { Some(name) } else { None }

View file

@ -102,7 +102,6 @@ impl UnixDatagram {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixDatagram};
///
/// fn main() -> std::io::Result<()> {
@ -119,7 +118,7 @@ impl UnixDatagram {
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixDatagram> {
unsafe {
let socket = UnixDatagram::unbound()?;
@ -217,7 +216,6 @@ impl UnixDatagram {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixDatagram};
///
/// fn main() -> std::io::Result<()> {
@ -235,7 +233,7 @@ impl UnixDatagram {
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub fn connect_addr(&self, socket_addr: &SocketAddr) -> io::Result<()> {
unsafe {
cvt(libc::connect(
@ -523,7 +521,6 @@ impl UnixDatagram {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixDatagram};
///
/// fn main() -> std::io::Result<()> {
@ -535,7 +532,7 @@ impl UnixDatagram {
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub fn send_to_addr(&self, buf: &[u8], socket_addr: &SocketAddr) -> io::Result<usize> {
unsafe {
let count = cvt(libc::sendto(

View file

@ -90,7 +90,6 @@ impl UnixListener {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixListener};
///
/// fn main() -> std::io::Result<()> {
@ -107,7 +106,7 @@ impl UnixListener {
/// Ok(())
/// }
/// ```
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixListener> {
unsafe {
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;

View file

@ -106,7 +106,6 @@ impl UnixStream {
/// # Examples
///
/// ```no_run
/// #![feature(unix_socket_abstract)]
/// use std::os::unix::net::{UnixListener, UnixStream};
///
/// fn main() -> std::io::Result<()> {
@ -123,7 +122,7 @@ impl UnixStream {
/// Ok(())
/// }
/// ````
#[unstable(feature = "unix_socket_abstract", issue = "85410")]
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
pub fn connect_addr(socket_addr: &SocketAddr) -> io::Result<UnixStream> {
unsafe {
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;