Repository: rust-lang/socket2
Pull request #550 (2025-01-27 05:26:57)

Fix docs link for AsFd
AsFd was moved in 1.66 which broke the old docs link.


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index fbb7fea..c8656f0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,7 @@
 [package]
 name          = "socket2"
-version       = "0.5.8"
+version       = "0.6.0"
+publish       = false # In development.
 authors       = [
   "Alex Crichton <alex@alexcrichton.com>",
   "Thomas de Zeeuw <thomasdezeeuw@gmail.com>"
diff --git a/src/socket.rs b/src/socket.rs
index 698d355..e6cdca2 100644
--- a/src/socket.rs
+++ b/src/socket.rs
@@ -1139,21 +1139,11 @@ const fn into_linger(duration: Option<Duration>) -> sys::linger {
 /// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
 /// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
 impl Socket {
-    /// This method is deprecated, use [`crate::Socket::header_included_v4`].
-    #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
-    #[cfg_attr(
-        docsrs,
-        doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf")))))
-    )]
-    #[deprecated = "Use `Socket::header_included_v4` instead"]
-    pub fn header_included(&self) -> io::Result<bool> {
-        self.header_included_v4()
-    }
     /// Get the value of the `IP_HDRINCL` option on this socket.
     ///
-    /// For more information about this option, see [`set_header_included`].
+    /// For more information about this option, see [`set_header_included_v4`].
     ///
-    /// [`set_header_included`]: Socket::set_header_included
+    /// [`set_header_included_v4`]: Socket::set_header_included_v4
     #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
     #[cfg_attr(
         docsrs,
@@ -1166,21 +1156,6 @@ impl Socket {
         }
     }
 
-    /// This method is deprecated, use [`crate::Socket::set_header_included_v4`].
-    #[cfg_attr(
-        any(target_os = "fuchsia", target_os = "illumos", target_os = "solaris"),
-        allow(rustdoc::broken_intra_doc_links)
-    )]
-    #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
-    #[cfg_attr(
-        docsrs,
-        doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf")))))
-    )]
-    #[deprecated = "Use `Socket::set_header_included_v4` instead"]
-    pub fn set_header_included(&self, included: bool) -> io::Result<()> {
-        self.set_header_included_v4(included)
-    }
-
     /// Set the value of the `IP_HDRINCL` option on this socket.
     ///
     /// If enabled, the user supplies an IP header in front of the user data.
@@ -1190,8 +1165,8 @@ impl Socket {
     ///
     /// [`SOCK_RAW`]: Type::RAW
     /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html
-    /// [`IP_TTL`]: Socket::set_ttl
-    /// [`IP_TOS`]: Socket::set_tos
+    /// [`IP_TTL`]: Socket::set_ttl_v4
+    /// [`IP_TOS`]: Socket::set_tos_v4
     #[cfg_attr(
         any(target_os = "fuchsia", target_os = "illumos", target_os = "solaris"),
         allow(rustdoc::broken_intra_doc_links)
@@ -1214,12 +1189,12 @@ impl Socket {
 
     /// Get the value of the `IP_TRANSPARENT` option on this socket.
     ///
-    /// For more information about this option, see [`set_ip_transparent`].
+    /// For more information about this option, see [`set_ip_transparent_v4`].
     ///
-    /// [`set_ip_transparent`]: Socket::set_ip_transparent
+    /// [`set_ip_transparent_v4`]: Socket::set_ip_transparent_v4
     #[cfg(all(feature = "all", target_os = "linux"))]
     #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
-    pub fn ip_transparent(&self) -> io::Result<bool> {
+    pub fn ip_transparent_v4(&self) -> io::Result<bool> {
         unsafe {
             getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, libc::IP_TRANSPARENT)
                 .map(|transparent| transparent != 0)
@@ -1243,7 +1218,7 @@ impl Socket {
     /// requires that this option be set on the redirected socket.
     #[cfg(all(feature = "all", target_os = "linux"))]
     #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
-    pub fn set_ip_transparent(&self, transparent: bool) -> io::Result<()> {
+    pub fn set_ip_transparent_v4(&self, transparent: bool) -> io::Result<()> {
         unsafe {
             setsockopt(
                 self.as_raw(),
@@ -1556,10 +1531,10 @@ impl Socket {
 
     /// Get the value of the `IP_TTL` option for this socket.
     ///
-    /// For more information about this option, see [`set_ttl`].
+    /// For more information about this option, see [`set_ttl_v4`].
     ///
-    /// [`set_ttl`]: Socket::set_ttl
-    pub fn ttl(&self) -> io::Result<u32> {
+    /// [`set_ttl_v4`]: Socket::set_ttl_v4
+    pub fn ttl_v4(&self) -> io::Result<u32> {
         unsafe {
             getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_TTL).map(|ttl| ttl as u32)
         }
@@ -1569,7 +1544,7 @@ impl Socket {
     ///
     /// This value sets the time-to-live field that is used in every packet sent
     /// from this socket.
-    pub fn set_ttl(&self, ttl: u32) -> io::Result<()> {
+    pub fn set_ttl_v4(&self, ttl: u32) -> io::Result<()> {
         unsafe { setsockopt(self.as_raw(), sys::IPPROTO_IP, sys::IP_TTL, ttl as c_int) }
     }
 
@@ -1587,18 +1562,18 @@ impl Socket {
         target_os = "illumos",
         target_os = "haiku",
     )))]
-    pub fn set_tos(&self, tos: u32) -> io::Result<()> {
+    pub fn set_tos_v4(&self, tos: u32) -> io::Result<()> {
         unsafe { setsockopt(self.as_raw(), sys::IPPROTO_IP, sys::IP_TOS, tos as c_int) }
     }
 
     /// Get the value of the `IP_TOS` option for this socket.
     ///
-    /// For more information about this option, see [`set_tos`].
+    /// For more information about this option, see [`set_tos_v4`].
     ///
     /// NOTE: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
     /// documents that not all versions of windows support `IP_TOS`.
     ///
-    /// [`set_tos`]: Socket::set_tos
+    /// [`set_tos_v4`]: Socket::set_tos_v4
     #[cfg(not(any(
         target_os = "fuchsia",
         target_os = "redox",
@@ -1606,7 +1581,7 @@ impl Socket {
         target_os = "illumos",
         target_os = "haiku",
     )))]
-    pub fn tos(&self) -> io::Result<u32> {
+    pub fn tos_v4(&self) -> io::Result<u32> {
         unsafe {
             getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_TOS).map(|tos| tos as u32)
         }
@@ -1632,7 +1607,7 @@ impl Socket {
         target_os = "espidf",
         target_os = "vita",
     )))]
-    pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> {
+    pub fn set_recv_tos_v4(&self, recv_tos: bool) -> io::Result<()> {
         unsafe {
             setsockopt(
                 self.as_raw(),
@@ -1645,9 +1620,9 @@ impl Socket {
 
     /// Get the value of the `IP_RECVTOS` option for this socket.
     ///
-    /// For more information about this option, see [`set_recv_tos`].
+    /// For more information about this option, see [`set_recv_tos_v4`].
     ///
-    /// [`set_recv_tos`]: Socket::set_recv_tos
+    /// [`set_recv_tos_v4`]: Socket::set_recv_tos_v4
     #[cfg(not(any(
         target_os = "aix",
         target_os = "dragonfly",
@@ -1663,7 +1638,7 @@ impl Socket {
         target_os = "espidf",
         target_os = "vita",
     )))]
-    pub fn recv_tos(&self) -> io::Result<bool> {
+    pub fn recv_tos_v4(&self) -> io::Result<bool> {
         unsafe {
             getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_RECVTOS)
                 .map(|recv_tos| recv_tos > 0)
@@ -1679,9 +1654,9 @@ impl Socket {
 impl Socket {
     /// Get the value of the `IP_HDRINCL` option on this socket.
     ///
-    /// For more information about this option, see [`set_header_included`].
+    /// For more information about this option, see [`set_header_included_v6`].
     ///
-    /// [`set_header_included`]: Socket::set_header_included
+    /// [`set_header_included_v6`]: Socket::set_header_included_v6
     #[cfg(all(
         feature = "all",
         not(any(
diff --git a/src/sockref.rs b/src/sockref.rs
index d23b7c0..94b84dd 100644
--- a/src/sockref.rs
+++ b/src/sockref.rs
@@ -20,7 +20,7 @@ use crate::Socket;
 ///
 /// [`TcpStream`]: std::net::TcpStream
 // Don't use intra-doc links because they won't build on every platform.
-/// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.AsFd.html
+/// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsFd.html
 /// [`AsSocket`]: https://doc.rust-lang.org/stable/std/os/windows/io/trait.AsSocket.html
 ///
 /// # Examples
diff --git a/src/sys/unix.rs b/src/sys/unix.rs
index b40c3df..05cb2e9 100644
--- a/src/sys/unix.rs
+++ b/src/sys/unix.rs
@@ -2029,35 +2029,6 @@ impl crate::Socket {
         .map(|_| ())
     }
 
-    /// This method is deprecated, use [`crate::Socket::bind_device_by_index_v4`].
-    #[cfg(all(
-        feature = "all",
-        any(
-            target_os = "ios",
-            target_os = "visionos",
-            target_os = "macos",
-            target_os = "tvos",
-            target_os = "watchos",
-        )
-    ))]
-    #[cfg_attr(
-        docsrs,
-        doc(cfg(all(
-            feature = "all",
-            any(
-                target_os = "ios",
-                target_os = "visionos",
-                target_os = "macos",
-                target_os = "tvos",
-                target_os = "watchos",
-            )
-        )))
-    )]
-    #[deprecated = "Use `Socket::bind_device_by_index_v4` instead"]
-    pub fn bind_device_by_index(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
-        self.bind_device_by_index_v4(interface)
-    }
-
     /// Sets the value for `IP_BOUND_IF` option on this socket.
     ///
     /// If a socket is bound to an interface, only packets received from that
@@ -2168,35 +2139,6 @@ impl crate::Socket {
         Ok(NonZeroU32::new(index))
     }
 
-    /// This method is deprecated, use [`crate::Socket::device_index_v4`].
-    #[cfg(all(
-        feature = "all",
-        any(
-            target_os = "ios",
-            target_os = "visionos",
-            target_os = "macos",
-            target_os = "tvos",
-            target_os = "watchos",
-        )
-    ))]
-    #[cfg_attr(
-        docsrs,
-        doc(cfg(all(
-            feature = "all",
-            any(
-                target_os = "ios",
-                target_os = "visionos",
-                target_os = "macos",
-                target_os = "tvos",
-                target_os = "watchos",
-            )
-        )))
-    )]
-    #[deprecated = "Use `Socket::device_index_v4` instead"]
-    pub fn device_index(&self) -> io::Result<Option<NonZeroU32>> {
-        self.device_index_v4()
-    }
-
     /// Gets the value for `IPV6_BOUND_IF` option on this socket, i.e. the index
     /// for the interface to which the socket is bound.
     ///


Test patch:
diff --git a/tests/socket.rs b/tests/socket.rs
index 98a535c..3776a4b 100644
--- a/tests/socket.rs
+++ b/tests/socket.rs
@@ -1366,8 +1366,8 @@ test!(
 #[cfg(all(feature = "all", target_os = "linux"))]
 test!(
     #[ignore = "setting `IP_TRANSPARENT` requires the `CAP_NET_ADMIN` capability (works when running as root)"]
-    ip_transparent,
-    set_ip_transparent(true)
+    ip_transparent_v4,
+    set_ip_transparent_v4(true)
 );
 #[cfg(all(feature = "all", any(target_os = "fuchsia", target_os = "linux")))]
 test!(
@@ -1401,7 +1401,7 @@ test!(freebind, set_freebind(true));
 #[cfg(all(feature = "all", target_os = "linux"))]
 test!(IPv6 freebind_ipv6, set_freebind_ipv6(true));
 
-test!(IPv4 ttl, set_ttl(40));
+test!(IPv4 ttl_v4, set_ttl_v4(40));
 
 #[cfg(not(any(
     target_os = "fuchsia",
@@ -1410,7 +1410,7 @@ test!(IPv4 ttl, set_ttl(40));
     target_os = "illumos",
     target_os = "haiku",
 )))]
-test!(IPv4 tos, set_tos(96));
+test!(IPv4 tos_v4, set_tos_v4(96));
 
 #[cfg(not(any(
     target_os = "dragonfly",
@@ -1425,7 +1425,7 @@ test!(IPv4 tos, set_tos(96));
     target_os = "vita",
     target_os = "haiku",
 )))]
-test!(IPv4 recv_tos, set_recv_tos(true));
+test!(IPv4 recv_tos_v4, set_recv_tos_v4(true));
 
 #[cfg(not(windows))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows.
 test!(IPv4 broadcast, set_broadcast(true));