Stabilise unix_socket_abstract
Fixes https://github.com/rust-lang/rust/issues/85410
This commit is contained in:
parent
13afbdaa06
commit
a3f3db842d
8 changed files with 15 additions and 20 deletions
|
@ -1,8 +1,8 @@
|
||||||
//! Android-specific networking functionality.
|
//! 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;
|
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
|
||||||
|
|
||||||
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
//! Linux-specific networking functionality.
|
//! 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;
|
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
|
||||||
|
|
||||||
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::os::unix::net::SocketAddr;
|
||||||
use crate::sealed::Sealed;
|
use crate::sealed::Sealed;
|
||||||
|
|
||||||
/// Platform-specific extensions to [`SocketAddr`].
|
/// 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 {
|
pub trait SocketAddrExt: Sealed {
|
||||||
/// Creates a Unix socket address in the abstract namespace.
|
/// Creates a Unix socket address in the abstract namespace.
|
||||||
///
|
///
|
||||||
|
@ -22,7 +22,6 @@ pub trait SocketAddrExt: Sealed {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
||||||
/// use std::os::linux::net::SocketAddrExt;
|
/// use std::os::linux::net::SocketAddrExt;
|
||||||
///
|
///
|
||||||
|
@ -38,6 +37,7 @@ pub trait SocketAddrExt: Sealed {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
|
||||||
fn from_abstract_name<N>(name: N) -> crate::io::Result<SocketAddr>
|
fn from_abstract_name<N>(name: N) -> crate::io::Result<SocketAddr>
|
||||||
where
|
where
|
||||||
N: AsRef<[u8]>;
|
N: AsRef<[u8]>;
|
||||||
|
@ -47,7 +47,6 @@ pub trait SocketAddrExt: Sealed {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
||||||
/// use std::os::linux::net::SocketAddrExt;
|
/// use std::os::linux::net::SocketAddrExt;
|
||||||
///
|
///
|
||||||
|
@ -60,5 +59,6 @@ pub trait SocketAddrExt: Sealed {
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[stable(feature = "unix_socket_abstract", since = "CURRENT_RUSTC_VERSION")]
|
||||||
fn as_abstract_name(&self) -> Option<&[u8]>;
|
fn as_abstract_name(&self) -> Option<&[u8]>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#![doc(cfg(any(target_os = "linux", target_os = "android")))]
|
#![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;
|
pub(crate) mod addr;
|
||||||
|
|
||||||
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
#[unstable(feature = "tcp_quickack", issue = "96256")]
|
||||||
|
|
|
@ -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 {}
|
impl Sealed for SocketAddr {}
|
||||||
|
|
||||||
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
|
#[doc(cfg(any(target_os = "android", target_os = "linux")))]
|
||||||
#[cfg(any(doc, 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 {
|
impl linux_ext::addr::SocketAddrExt for SocketAddr {
|
||||||
fn as_abstract_name(&self) -> Option<&[u8]> {
|
fn as_abstract_name(&self) -> Option<&[u8]> {
|
||||||
if let AddressKind::Abstract(name) = self.address() { Some(name) } else { None }
|
if let AddressKind::Abstract(name) = self.address() { Some(name) } else { None }
|
||||||
|
|
|
@ -102,7 +102,6 @@ impl UnixDatagram {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixDatagram};
|
/// use std::os::unix::net::{UnixDatagram};
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
|
@ -119,7 +118,7 @@ impl UnixDatagram {
|
||||||
/// Ok(())
|
/// 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> {
|
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixDatagram> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let socket = UnixDatagram::unbound()?;
|
let socket = UnixDatagram::unbound()?;
|
||||||
|
@ -217,7 +216,6 @@ impl UnixDatagram {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixDatagram};
|
/// use std::os::unix::net::{UnixDatagram};
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
|
@ -235,7 +233,7 @@ impl UnixDatagram {
|
||||||
/// Ok(())
|
/// 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<()> {
|
pub fn connect_addr(&self, socket_addr: &SocketAddr) -> io::Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
cvt(libc::connect(
|
cvt(libc::connect(
|
||||||
|
@ -523,7 +521,6 @@ impl UnixDatagram {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixDatagram};
|
/// use std::os::unix::net::{UnixDatagram};
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
|
@ -535,7 +532,7 @@ impl UnixDatagram {
|
||||||
/// Ok(())
|
/// 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> {
|
pub fn send_to_addr(&self, buf: &[u8], socket_addr: &SocketAddr) -> io::Result<usize> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let count = cvt(libc::sendto(
|
let count = cvt(libc::sendto(
|
||||||
|
|
|
@ -90,7 +90,6 @@ impl UnixListener {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixListener};
|
/// use std::os::unix::net::{UnixListener};
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
|
@ -107,7 +106,7 @@ impl UnixListener {
|
||||||
/// Ok(())
|
/// 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> {
|
pub fn bind_addr(socket_addr: &SocketAddr) -> io::Result<UnixListener> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
||||||
|
|
|
@ -106,7 +106,6 @@ impl UnixStream {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #![feature(unix_socket_abstract)]
|
|
||||||
/// use std::os::unix::net::{UnixListener, UnixStream};
|
/// use std::os::unix::net::{UnixListener, UnixStream};
|
||||||
///
|
///
|
||||||
/// fn main() -> std::io::Result<()> {
|
/// fn main() -> std::io::Result<()> {
|
||||||
|
@ -123,7 +122,7 @@ impl UnixStream {
|
||||||
/// Ok(())
|
/// 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> {
|
pub fn connect_addr(socket_addr: &SocketAddr) -> io::Result<UnixStream> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
let inner = Socket::new_raw(libc::AF_UNIX, libc::SOCK_STREAM)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue