Move to intra doc links in std::net

This commit is contained in:
Alexis Bourget 2020-08-15 19:17:19 +02:00
parent b9db927b68
commit 15cad1c465
6 changed files with 139 additions and 293 deletions

View File

@ -22,10 +22,6 @@ use crate::vec;
/// The size of a `SocketAddr` instance may vary depending on the target operating /// The size of a `SocketAddr` instance may vary depending on the target operating
/// system. /// system.
/// ///
/// [IP address]: ../../std/net/enum.IpAddr.html
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -50,7 +46,7 @@ pub enum SocketAddr {
/// An IPv4 socket address. /// An IPv4 socket address.
/// ///
/// IPv4 socket addresses consist of an [IPv4 address] and a 16-bit port number, as /// IPv4 socket addresses consist of an [`IPv4` address] and a 16-bit port number, as
/// stated in [IETF RFC 793]. /// stated in [IETF RFC 793].
/// ///
/// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses. /// See [`SocketAddr`] for a type encompassing both IPv4 and IPv6 socket addresses.
@ -59,8 +55,7 @@ pub enum SocketAddr {
/// system. /// system.
/// ///
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793 /// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
/// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html /// [`IPv4` address]: Ipv4Addr
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// ///
/// # Examples /// # Examples
/// ///
@ -81,7 +76,7 @@ pub struct SocketAddrV4 {
/// An IPv6 socket address. /// An IPv6 socket address.
/// ///
/// IPv6 socket addresses consist of an [Ipv6 address], a 16-bit port number, as well /// IPv6 socket addresses consist of an [`IPv6` address], a 16-bit port number, as well
/// as fields containing the traffic class, the flow label, and a scope identifier /// as fields containing the traffic class, the flow label, and a scope identifier
/// (see [IETF RFC 2553, Section 3.3] for more details). /// (see [IETF RFC 2553, Section 3.3] for more details).
/// ///
@ -91,8 +86,7 @@ pub struct SocketAddrV4 {
/// system. /// system.
/// ///
/// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3 /// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3
/// [IPv6 address]: ../../std/net/struct.Ipv6Addr.html /// [`IPv6` address]: Ipv6Addr
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// ///
/// # Examples /// # Examples
/// ///
@ -114,7 +108,7 @@ pub struct SocketAddrV6 {
impl SocketAddr { impl SocketAddr {
/// Creates a new socket address from an [IP address] and a port number. /// Creates a new socket address from an [IP address] and a port number.
/// ///
/// [IP address]: ../../std/net/enum.IpAddr.html /// [IP address]: IpAddr
/// ///
/// # Examples /// # Examples
/// ///
@ -210,12 +204,12 @@ impl SocketAddr {
} }
/// Returns [`true`] if the [IP address] in this `SocketAddr` is an /// Returns [`true`] if the [IP address] in this `SocketAddr` is an
/// [IPv4 address], and [`false`] otherwise. /// [`IPv4` address], and [`false`] otherwise.
/// ///
/// [`true`]: ../../std/primitive.bool.html /// [IP address]: IpAddr
/// [`IPv4` address]: IpAddr::V4
/// [`false`]: ../../std/primitive.bool.html /// [`false`]: ../../std/primitive.bool.html
/// [IP address]: ../../std/net/enum.IpAddr.html /// [`true`]: ../../std/primitive.bool.html
/// [IPv4 address]: ../../std/net/enum.IpAddr.html#variant.V4
/// ///
/// # Examples /// # Examples
/// ///
@ -232,12 +226,12 @@ impl SocketAddr {
} }
/// Returns [`true`] if the [IP address] in this `SocketAddr` is an /// Returns [`true`] if the [IP address] in this `SocketAddr` is an
/// [IPv6 address], and [`false`] otherwise. /// [`IPv6` address], and [`false`] otherwise.
/// ///
/// [`true`]: ../../std/primitive.bool.html /// [IP address]: IpAddr
/// [`IPv6` address]: IpAddr::V6
/// [`false`]: ../../std/primitive.bool.html /// [`false`]: ../../std/primitive.bool.html
/// [IP address]: ../../std/net/enum.IpAddr.html /// [`true`]: ../../std/primitive.bool.html
/// [IPv6 address]: ../../std/net/enum.IpAddr.html#variant.V6
/// ///
/// # Examples /// # Examples
/// ///
@ -255,9 +249,9 @@ impl SocketAddr {
} }
impl SocketAddrV4 { impl SocketAddrV4 {
/// Creates a new socket address from an [IPv4 address] and a port number. /// Creates a new socket address from an [`IPv4` address] and a port number.
/// ///
/// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html /// [`IPv4` address]: Ipv4Addr
/// ///
/// # Examples /// # Examples
/// ///
@ -342,14 +336,14 @@ impl SocketAddrV4 {
} }
impl SocketAddrV6 { impl SocketAddrV6 {
/// Creates a new socket address from an [IPv6 address], a 16-bit port number, /// Creates a new socket address from an [`IPv6` address], a 16-bit port number,
/// and the `flowinfo` and `scope_id` fields. /// and the `flowinfo` and `scope_id` fields.
/// ///
/// For more information on the meaning and layout of the `flowinfo` and `scope_id` /// For more information on the meaning and layout of the `flowinfo` and `scope_id`
/// parameters, see [IETF RFC 2553, Section 3.3]. /// parameters, see [IETF RFC 2553, Section 3.3].
/// ///
/// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3 /// [IETF RFC 2553, Section 3.3]: https://tools.ietf.org/html/rfc2553#section-3.3
/// [IPv6 address]: ../../std/net/struct.Ipv6Addr.html /// [`IPv6` address]: Ipv6Addr
/// ///
/// # Examples /// # Examples
/// ///
@ -461,9 +455,7 @@ impl SocketAddrV6 {
/// Changes the flow information associated with this socket address. /// Changes the flow information associated with this socket address.
/// ///
/// See the [`flowinfo`] method's documentation for more details. /// See [`SocketAddrV6::flowinfo`]'s documentation for more details.
///
/// [`flowinfo`]: #method.flowinfo
/// ///
/// # Examples /// # Examples
/// ///
@ -501,9 +493,7 @@ impl SocketAddrV6 {
/// Changes the scope ID associated with this socket address. /// Changes the scope ID associated with this socket address.
/// ///
/// See the [`scope_id`] method's documentation for more details. /// See [`SocketAddrV6::scope_id`]'s documentation for more details.
///
/// [`scope_id`]: #method.scope_id
/// ///
/// # Examples /// # Examples
/// ///
@ -535,9 +525,6 @@ impl FromInner<c::sockaddr_in6> for SocketAddrV6 {
#[stable(feature = "ip_from_ip", since = "1.16.0")] #[stable(feature = "ip_from_ip", since = "1.16.0")]
impl From<SocketAddrV4> for SocketAddr { impl From<SocketAddrV4> for SocketAddr {
/// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`]. /// Converts a [`SocketAddrV4`] into a [`SocketAddr::V4`].
///
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
/// [`SocketAddr::V4`]: ../../std/net/enum.SocketAddr.html#variant.V4
fn from(sock4: SocketAddrV4) -> SocketAddr { fn from(sock4: SocketAddrV4) -> SocketAddr {
SocketAddr::V4(sock4) SocketAddr::V4(sock4)
} }
@ -546,9 +533,6 @@ impl From<SocketAddrV4> for SocketAddr {
#[stable(feature = "ip_from_ip", since = "1.16.0")] #[stable(feature = "ip_from_ip", since = "1.16.0")]
impl From<SocketAddrV6> for SocketAddr { impl From<SocketAddrV6> for SocketAddr {
/// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`]. /// Converts a [`SocketAddrV6`] into a [`SocketAddr::V6`].
///
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
/// [`SocketAddr::V6`]: ../../std/net/enum.SocketAddr.html#variant.V6
fn from(sock6: SocketAddrV6) -> SocketAddr { fn from(sock6: SocketAddrV6) -> SocketAddr {
SocketAddr::V6(sock6) SocketAddr::V6(sock6)
} }
@ -562,13 +546,6 @@ impl<I: Into<IpAddr>> From<(I, u16)> for SocketAddr {
/// and creates a [`SocketAddr::V6`] for a [`IpAddr::V6`]. /// and creates a [`SocketAddr::V6`] for a [`IpAddr::V6`].
/// ///
/// `u16` is treated as port of the newly created [`SocketAddr`]. /// `u16` is treated as port of the newly created [`SocketAddr`].
///
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// [`IpAddr::V4`]: ../../std/net/enum.IpAddr.html#variant.V4
/// [`IpAddr::V6`]: ../../std/net/enum.IpAddr.html#variant.V6
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// [`SocketAddr::V4`]: ../../std/net/enum.SocketAddr.html#variant.V4
/// [`SocketAddr::V6`]: ../../std/net/enum.SocketAddr.html#variant.V6
fn from(pieces: (I, u16)) -> SocketAddr { fn from(pieces: (I, u16)) -> SocketAddr {
SocketAddr::new(pieces.0.into(), pieces.1) SocketAddr::new(pieces.0.into(), pieces.1)
} }
@ -785,18 +762,11 @@ impl hash::Hash for SocketAddrV6 {
/// Addresses returned by the operating system that are not IP addresses are /// Addresses returned by the operating system that are not IP addresses are
/// silently ignored. /// silently ignored.
/// ///
/// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`FromStr`]: crate::str::FromStr
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html /// [`&str`]: str
/// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html /// [`TcpStream`]: crate::net::TcpStream
/// [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html /// [`to_socket_addrs`]: ToSocketAddrs::to_socket_addrs
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html /// [`UdpSocket`]: crate::net::UdpSocket
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
/// [`&str`]: ../../std/primitive.str.html
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
/// [`to_socket_addrs`]: #tymethod.to_socket_addrs
/// [`UdpSocket`]: ../../std/net/struct.UdpSocket.html
/// [`u16`]: ../../std/primitive.u16.html
/// ///
/// # Examples /// # Examples
/// ///
@ -867,7 +837,7 @@ impl hash::Hash for SocketAddrV6 {
/// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443)); /// let stream = TcpStream::connect((Ipv4Addr::new(127, 0, 0, 1), 443));
/// ``` /// ```
/// ///
/// [`TcpStream::connect`]: ../../std/net/struct.TcpStream.html#method.connect /// [`TcpStream::connect`]: crate::net::TcpStream::connect
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub trait ToSocketAddrs { pub trait ToSocketAddrs {
/// Returned iterator over socket addresses which this type may correspond /// Returned iterator over socket addresses which this type may correspond

View File

@ -22,9 +22,6 @@ use crate::sys_common::{AsInner, FromInner};
/// The size of an `IpAddr` instance may vary depending on the target operating /// The size of an `IpAddr` instance may vary depending on the target operating
/// system. /// system.
/// ///
/// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
/// [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -61,14 +58,13 @@ pub enum IpAddr {
/// system. /// system.
/// ///
/// [IETF RFC 791]: https://tools.ietf.org/html/rfc791 /// [IETF RFC 791]: https://tools.ietf.org/html/rfc791
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// ///
/// # Textual representation /// # Textual representation
/// ///
/// `Ipv4Addr` provides a [`FromStr`] implementation. The four octets are in decimal /// `Ipv4Addr` provides a [`FromStr`] implementation. The four octets are in decimal
/// notation, divided by `.` (this is called "dot-decimal notation"). /// notation, divided by `.` (this is called "dot-decimal notation").
/// ///
/// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`FromStr`]: crate::str::FromStr
/// ///
/// # Examples /// # Examples
/// ///
@ -96,7 +92,6 @@ pub struct Ipv4Addr {
/// system. /// system.
/// ///
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291 /// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// ///
/// # Textual representation /// # Textual representation
/// ///
@ -105,7 +100,7 @@ pub struct Ipv4Addr {
/// notation, and segments are separated by `:`. For more information, see /// notation, and segments are separated by `:`. For more information, see
/// [IETF RFC 5952]. /// [IETF RFC 5952].
/// ///
/// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`FromStr`]: crate::str::FromStr
/// [IETF RFC 5952]: https://tools.ietf.org/html/rfc5952 /// [IETF RFC 5952]: https://tools.ietf.org/html/rfc5952
/// ///
/// # Examples /// # Examples
@ -138,11 +133,9 @@ pub enum Ipv6MulticastScope {
impl IpAddr { impl IpAddr {
/// Returns [`true`] for the special 'unspecified' address. /// Returns [`true`] for the special 'unspecified' address.
/// ///
/// See the documentation for [`Ipv4Addr::is_unspecified`][IPv4] and /// See the documentation for [`Ipv4Addr::is_unspecified`] and
/// [`Ipv6Addr::is_unspecified`][IPv6] for more details. /// [`Ipv6Addr::is_unspecified`] for more details.
/// ///
/// [IPv4]: ../../std/net/struct.Ipv4Addr.html#method.is_unspecified
/// [IPv6]: ../../std/net/struct.Ipv6Addr.html#method.is_unspecified
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -163,11 +156,9 @@ impl IpAddr {
/// Returns [`true`] if this is a loopback address. /// Returns [`true`] if this is a loopback address.
/// ///
/// See the documentation for [`Ipv4Addr::is_loopback`][IPv4] and /// See the documentation for [`Ipv4Addr::is_loopback`] and
/// [`Ipv6Addr::is_loopback`][IPv6] for more details. /// [`Ipv6Addr::is_loopback`] for more details.
/// ///
/// [IPv4]: ../../std/net/struct.Ipv4Addr.html#method.is_loopback
/// [IPv6]: ../../std/net/struct.Ipv6Addr.html#method.is_loopback
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -188,11 +179,9 @@ impl IpAddr {
/// Returns [`true`] if the address appears to be globally routable. /// Returns [`true`] if the address appears to be globally routable.
/// ///
/// See the documentation for [`Ipv4Addr::is_global`][IPv4] and /// See the documentation for [`Ipv4Addr::is_global`] and
/// [`Ipv6Addr::is_global`][IPv6] for more details. /// [`Ipv6Addr::is_global`] for more details.
/// ///
/// [IPv4]: ../../std/net/struct.Ipv4Addr.html#method.is_global
/// [IPv6]: ../../std/net/struct.Ipv6Addr.html#method.is_global
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -214,11 +203,9 @@ impl IpAddr {
/// Returns [`true`] if this is a multicast address. /// Returns [`true`] if this is a multicast address.
/// ///
/// See the documentation for [`Ipv4Addr::is_multicast`][IPv4] and /// See the documentation for [`Ipv4Addr::is_multicast`] and
/// [`Ipv6Addr::is_multicast`][IPv6] for more details. /// [`Ipv6Addr::is_multicast`] for more details.
/// ///
/// [IPv4]: ../../std/net/struct.Ipv4Addr.html#method.is_multicast
/// [IPv6]: ../../std/net/struct.Ipv6Addr.html#method.is_multicast
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -239,11 +226,9 @@ impl IpAddr {
/// Returns [`true`] if this address is in a range designated for documentation. /// Returns [`true`] if this address is in a range designated for documentation.
/// ///
/// See the documentation for [`Ipv4Addr::is_documentation`][IPv4] and /// See the documentation for [`Ipv4Addr::is_documentation`] and
/// [`Ipv6Addr::is_documentation`][IPv6] for more details. /// [`Ipv6Addr::is_documentation`] for more details.
/// ///
/// [IPv4]: ../../std/net/struct.Ipv4Addr.html#method.is_documentation
/// [IPv6]: ../../std/net/struct.Ipv6Addr.html#method.is_documentation
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -266,11 +251,12 @@ impl IpAddr {
} }
} }
/// Returns [`true`] if this address is an [IPv4 address], and [`false`] otherwise. /// Returns [`true`] if this address is an [`IPv4` address], and [`false`]
/// otherwise.
/// ///
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [`false`]: ../../std/primitive.bool.html /// [`false`]: ../../std/primitive.bool.html
/// [IPv4 address]: #variant.V4 /// [`IPv4` address]: IpAddr::V4
/// ///
/// # Examples /// # Examples
/// ///
@ -285,11 +271,12 @@ impl IpAddr {
matches!(self, IpAddr::V4(_)) matches!(self, IpAddr::V4(_))
} }
/// Returns [`true`] if this address is an [IPv6 address], and [`false`] otherwise. /// Returns [`true`] if this address is an [`IPv6` address], and [`false`]
/// otherwise.
/// ///
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [`false`]: ../../std/primitive.bool.html /// [`false`]: ../../std/primitive.bool.html
/// [IPv6 address]: #variant.V6 /// [`IPv6` address]: IpAddr::V6
/// ///
/// # Examples /// # Examples
/// ///
@ -385,8 +372,8 @@ impl Ipv4Addr {
/// This property is defined in _UNIX Network Programming, Second Edition_, /// This property is defined in _UNIX Network Programming, Second Edition_,
/// W. Richard Stevens, p. 891; see also [ip7]. /// W. Richard Stevens, p. 891; see also [ip7].
/// ///
/// [ip7]: http://man7.org/linux/man-pages/man7/ip.7.html
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [ip7]: http://man7.org/linux/man-pages/man7/ip.7.html
/// ///
/// # Examples /// # Examples
/// ///
@ -406,8 +393,8 @@ impl Ipv4Addr {
/// ///
/// This property is defined by [IETF RFC 1122]. /// This property is defined by [IETF RFC 1122].
/// ///
/// [IETF RFC 1122]: https://tools.ietf.org/html/rfc1122
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 1122]: https://tools.ietf.org/html/rfc1122
/// ///
/// # Examples /// # Examples
/// ///
@ -430,8 +417,8 @@ impl Ipv4Addr {
/// - 172.16.0.0/12 /// - 172.16.0.0/12
/// - 192.168.0.0/16 /// - 192.168.0.0/16
/// ///
/// [IETF RFC 1918]: https://tools.ietf.org/html/rfc1918
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 1918]: https://tools.ietf.org/html/rfc1918
/// ///
/// # Examples /// # Examples
/// ///
@ -460,8 +447,8 @@ impl Ipv4Addr {
/// ///
/// This property is defined by [IETF RFC 3927]. /// This property is defined by [IETF RFC 3927].
/// ///
/// [IETF RFC 3927]: https://tools.ietf.org/html/rfc3927
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 3927]: https://tools.ietf.org/html/rfc3927
/// ///
/// # Examples /// # Examples
/// ///
@ -485,22 +472,22 @@ impl Ipv4Addr {
/// ///
/// The following return false: /// The following return false:
/// ///
/// - private addresses (see [`is_private()`](#method.is_private)) /// - private addresses (see [`Ipv4Addr::is_private`])
/// - the loopback address (see [`is_loopback()`](#method.is_loopback)) /// - the loopback address (see [`Ipv4Addr::is_loopback`])
/// - the link-local address (see [`is_link_local()`](#method.is_link_local)) /// - the link-local address (see [`Ipv4Addr::is_link_local`])
/// - the broadcast address (see [`is_broadcast()`](#method.is_broadcast)) /// - the broadcast address (see [`Ipv4Addr::is_broadcast`])
/// - addresses used for documentation (see [`is_documentation()`](#method.is_documentation)) /// - addresses used for documentation (see [`Ipv4Addr::is_documentation`])
/// - the unspecified address (see [`is_unspecified()`](#method.is_unspecified)), and the whole /// - the unspecified address (see [`Ipv4Addr::is_unspecified`]), and the whole
/// 0.0.0.0/8 block /// 0.0.0.0/8 block
/// - addresses reserved for future protocols (see /// - addresses reserved for future protocols (see
/// [`is_ietf_protocol_assignment()`](#method.is_ietf_protocol_assignment), except /// [`Ipv4Addr::is_ietf_protocol_assignment`], except
/// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable /// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable
/// - addresses reserved for future use (see [`is_reserved()`](#method.is_reserved) /// - addresses reserved for future use (see [`Ipv4Addr::is_reserved`]
/// - addresses reserved for networking devices benchmarking (see /// - addresses reserved for networking devices benchmarking (see
/// [`is_benchmarking`](#method.is_benchmarking)) /// [`Ipv4Addr::is_benchmarking`])
/// ///
/// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [ipv4-sr]: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
/// ///
/// # Examples /// # Examples
/// ///
@ -572,8 +559,8 @@ impl Ipv4Addr {
/// Returns [`true`] if this address is part of the Shared Address Space defined in /// Returns [`true`] if this address is part of the Shared Address Space defined in
/// [IETF RFC 6598] (`100.64.0.0/10`). /// [IETF RFC 6598] (`100.64.0.0/10`).
/// ///
/// [IETF RFC 6598]: https://tools.ietf.org/html/rfc6598
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 6598]: https://tools.ietf.org/html/rfc6598
/// ///
/// # Examples /// # Examples
/// ///
@ -598,11 +585,11 @@ impl Ipv4Addr {
/// - `192.0.0.9/32` is the "Port Control Protocol Anycast" (see [IETF RFC 7723]) /// - `192.0.0.9/32` is the "Port Control Protocol Anycast" (see [IETF RFC 7723])
/// - `192.0.0.10/32` is used for NAT traversal (see [IETF RFC 8155]) /// - `192.0.0.10/32` is used for NAT traversal (see [IETF RFC 8155])
/// ///
/// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 6890]: https://tools.ietf.org/html/rfc6890 /// [IETF RFC 6890]: https://tools.ietf.org/html/rfc6890
/// [IETF RFC 7600]: https://tools.ietf.org/html/rfc7600 /// [IETF RFC 7600]: https://tools.ietf.org/html/rfc7600
/// [IETF RFC 7723]: https://tools.ietf.org/html/rfc7723 /// [IETF RFC 7723]: https://tools.ietf.org/html/rfc7723
/// [IETF RFC 8155]: https://tools.ietf.org/html/rfc8155 /// [IETF RFC 8155]: https://tools.ietf.org/html/rfc8155
/// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
/// ///
@ -625,9 +612,9 @@ impl Ipv4Addr {
/// network devices benchmarking. This range is defined in [IETF RFC 2544] as `192.18.0.0` /// network devices benchmarking. This range is defined in [IETF RFC 2544] as `192.18.0.0`
/// through `198.19.255.255` but [errata 423] corrects it to `198.18.0.0/15`. /// through `198.19.255.255` but [errata 423] corrects it to `198.18.0.0/15`.
/// ///
/// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 2544]: https://tools.ietf.org/html/rfc2544 /// [IETF RFC 2544]: https://tools.ietf.org/html/rfc2544
/// [errata 423]: https://www.rfc-editor.org/errata/eid423 /// [errata 423]: https://www.rfc-editor.org/errata/eid423
/// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
/// ///
@ -649,8 +636,8 @@ impl Ipv4Addr {
/// broadcast address `255.255.255.255`, but this implementation explicitly excludes it, since /// broadcast address `255.255.255.255`, but this implementation explicitly excludes it, since
/// it is obviously not reserved for future use. /// it is obviously not reserved for future use.
/// ///
/// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112
/// ///
/// # Warning /// # Warning
/// ///
@ -681,8 +668,8 @@ impl Ipv4Addr {
/// Multicast addresses have a most significant octet between 224 and 239, /// Multicast addresses have a most significant octet between 224 and 239,
/// and is defined by [IETF RFC 5771]. /// and is defined by [IETF RFC 5771].
/// ///
/// [IETF RFC 5771]: https://tools.ietf.org/html/rfc5771
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 5771]: https://tools.ietf.org/html/rfc5771
/// ///
/// # Examples /// # Examples
/// ///
@ -702,8 +689,8 @@ impl Ipv4Addr {
/// ///
/// A broadcast address has all octets set to 255 as defined in [IETF RFC 919]. /// A broadcast address has all octets set to 255 as defined in [IETF RFC 919].
/// ///
/// [IETF RFC 919]: https://tools.ietf.org/html/rfc919
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 919]: https://tools.ietf.org/html/rfc919
/// ///
/// # Examples /// # Examples
/// ///
@ -726,8 +713,8 @@ impl Ipv4Addr {
/// - 198.51.100.0/24 (TEST-NET-2) /// - 198.51.100.0/24 (TEST-NET-2)
/// - 203.0.113.0/24 (TEST-NET-3) /// - 203.0.113.0/24 (TEST-NET-3)
/// ///
/// [IETF RFC 5737]: https://tools.ietf.org/html/rfc5737
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 5737]: https://tools.ietf.org/html/rfc5737
/// ///
/// # Examples /// # Examples
/// ///
@ -749,11 +736,11 @@ impl Ipv4Addr {
} }
} }
/// Converts this address to an IPv4-compatible [IPv6 address]. /// Converts this address to an IPv4-compatible [`IPv6` address].
/// ///
/// a.b.c.d becomes ::a.b.c.d /// a.b.c.d becomes ::a.b.c.d
/// ///
/// [IPv6 address]: ../../std/net/struct.Ipv6Addr.html /// [`IPv6` address]: Ipv6Addr
/// ///
/// # Examples /// # Examples
/// ///
@ -771,11 +758,11 @@ impl Ipv4Addr {
Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a, b, c, d]) Ipv6Addr::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, a, b, c, d])
} }
/// Converts this address to an IPv4-mapped [IPv6 address]. /// Converts this address to an IPv4-mapped [`IPv6` address].
/// ///
/// a.b.c.d becomes ::ffff:a.b.c.d /// a.b.c.d becomes ::ffff:a.b.c.d
/// ///
/// [IPv6 address]: ../../std/net/struct.Ipv6Addr.html /// [`IPv6` address]: Ipv6Addr
/// ///
/// # Examples /// # Examples
/// ///
@ -1128,8 +1115,8 @@ impl Ipv6Addr {
/// ///
/// This property is defined in [IETF RFC 4291]. /// This property is defined in [IETF RFC 4291].
/// ///
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// ///
/// # Examples /// # Examples
/// ///
@ -1148,8 +1135,8 @@ impl Ipv6Addr {
/// ///
/// This property is defined in [IETF RFC 4291]. /// This property is defined in [IETF RFC 4291].
/// ///
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// ///
/// # Examples /// # Examples
/// ///
@ -1199,6 +1186,7 @@ impl Ipv6Addr {
/// This property is defined in [IETF RFC 4193]. /// This property is defined in [IETF RFC 4193].
/// ///
/// [IETF RFC 4193]: https://tools.ietf.org/html/rfc4193 /// [IETF RFC 4193]: https://tools.ietf.org/html/rfc4193
///
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
@ -1230,7 +1218,9 @@ impl Ipv6Addr {
/// ///
/// This method validates the format defined in the RFC and won't recognize the following /// This method validates the format defined in the RFC and won't recognize the following
/// addresses such as `fe80:0:0:1::` or `fe81::` as unicast link-local addresses for example. /// addresses such as `fe80:0:0:1::` or `fe81::` as unicast link-local addresses for example.
/// If you need a less strict validation use [`is_unicast_link_local()`] instead. /// If you need a less strict validation use [`Ipv6Addr::is_unicast_link_local`] instead.
///
/// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
/// ///
@ -1259,13 +1249,11 @@ impl Ipv6Addr {
/// - [IETF RFC 4291 section 2.5.6] /// - [IETF RFC 4291 section 2.5.6]
/// - [RFC 4291 errata 4406] (which has been rejected but provides useful /// - [RFC 4291 errata 4406] (which has been rejected but provides useful
/// insight) /// insight)
/// - [`is_unicast_link_local()`] /// - [`Ipv6Addr::is_unicast_link_local`]
/// ///
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291 /// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6 /// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6
/// [`true`]: ../../std/primitive.bool.html
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
/// [`is_unicast_link_local()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local
pub fn is_unicast_link_local_strict(&self) -> bool { pub fn is_unicast_link_local_strict(&self) -> bool {
(self.segments()[0] & 0xffff) == 0xfe80 (self.segments()[0] & 0xffff) == 0xfe80
&& (self.segments()[1] & 0xffff) == 0 && (self.segments()[1] & 0xffff) == 0
@ -1287,9 +1275,11 @@ impl Ipv6Addr {
/// ``` /// ```
/// ///
/// As a result, this method consider addresses such as `fe80:0:0:1::` or `fe81::` to be /// As a result, this method consider addresses such as `fe80:0:0:1::` or `fe81::` to be
/// unicast link-local addresses, whereas [`is_unicast_link_local_strict()`] does not. If you /// unicast link-local addresses, whereas [`Ipv6Addr::is_unicast_link_local_strict`] does not.
/// need a strict validation fully compliant with the RFC, use /// If you need a strict validation fully compliant with the RFC, use
/// [`is_unicast_link_local_strict()`]. /// [`Ipv6Addr::is_unicast_link_local_strict`] instead.
///
/// [`true`]: ../../std/primitive.bool.html
/// ///
/// # Examples /// # Examples
/// ///
@ -1320,9 +1310,7 @@ impl Ipv6Addr {
/// insight) /// insight)
/// ///
/// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4 /// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4
/// [`true`]: ../../std/primitive.bool.html
/// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406
/// [`is_unicast_link_local_strict()`]: ../../std/net/struct.Ipv6Addr.html#method.is_unicast_link_local_strict
pub fn is_unicast_link_local(&self) -> bool { pub fn is_unicast_link_local(&self) -> bool {
(self.segments()[0] & 0xffc0) == 0xfe80 (self.segments()[0] & 0xffc0) == 0xfe80
} }
@ -1371,8 +1359,8 @@ impl Ipv6Addr {
/// ///
/// This property is defined in [IETF RFC 3849]. /// This property is defined in [IETF RFC 3849].
/// ///
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 3849]: https://tools.ietf.org/html/rfc3849
/// ///
/// # Examples /// # Examples
/// ///
@ -1464,8 +1452,8 @@ impl Ipv6Addr {
/// ///
/// This property is defined by [IETF RFC 4291]. /// This property is defined by [IETF RFC 4291].
/// ///
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// [`true`]: ../../std/primitive.bool.html /// [`true`]: ../../std/primitive.bool.html
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291
/// ///
/// # Examples /// # Examples
/// ///
@ -1480,14 +1468,13 @@ impl Ipv6Addr {
(self.segments()[0] & 0xff00) == 0xff00 (self.segments()[0] & 0xff00) == 0xff00
} }
/// Converts this address to an [IPv4 address] if it's an "IPv4-mapped IPv6 address" /// Converts this address to an [`IPv4` address] if it's an "IPv4-mapped IPv6 address"
/// defined in [IETF RFC 4291 section 2.5.5.2], otherwise returns [`None`]. /// defined in [IETF RFC 4291 section 2.5.5.2], otherwise returns [`None`].
/// ///
/// `::ffff:a.b.c.d` becomes `a.b.c.d`. /// `::ffff:a.b.c.d` becomes `a.b.c.d`.
/// All addresses *not* starting with `::ffff` will return `None`. /// All addresses *not* starting with `::ffff` will return `None`.
/// ///
/// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html /// [`IPv4` address]: Ipv4Addr
/// [`None`]: ../../std/option/enum.Option.html#variant.None
/// [IETF RFC 4291 section 2.5.5.2]: https://tools.ietf.org/html/rfc4291#section-2.5.5.2 /// [IETF RFC 4291 section 2.5.5.2]: https://tools.ietf.org/html/rfc4291#section-2.5.5.2
/// ///
/// # Examples /// # Examples
@ -1511,13 +1498,12 @@ impl Ipv6Addr {
} }
} }
/// Converts this address to an [IPv4 address]. Returns [`None`] if this address is /// Converts this address to an [`IPv4` address]. Returns [`None`] if this address is
/// neither IPv4-compatible or IPv4-mapped. /// neither IPv4-compatible or IPv4-mapped.
/// ///
/// ::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d /// ::a.b.c.d and ::ffff:a.b.c.d become a.b.c.d
/// ///
/// [IPv4 address]: ../../std/net/struct.Ipv4Addr.html /// [`IPv4` address]: Ipv4Addr
/// [`None`]: ../../std/option/enum.Option.html#variant.None
/// ///
/// # Examples /// # Examples
/// ///

View File

@ -14,17 +14,6 @@
//! * [`ToSocketAddrs`] is a trait that used for generic address resolution when interacting //! * [`ToSocketAddrs`] is a trait that used for generic address resolution when interacting
//! with networking objects like [`TcpListener`], [`TcpStream`] or [`UdpSocket`] //! with networking objects like [`TcpListener`], [`TcpStream`] or [`UdpSocket`]
//! * Other types are return or parameter types for various methods in this module //! * Other types are return or parameter types for various methods in this module
//!
//! [`IpAddr`]: ../../std/net/enum.IpAddr.html
//! [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
//! [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
//! [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
//! [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
//! [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
//! [`TcpListener`]: ../../std/net/struct.TcpListener.html
//! [`TcpStream`]: ../../std/net/struct.TcpStream.html
//! [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
//! [`UdpSocket`]: ../../std/net/struct.UdpSocket.html
#![stable(feature = "rust1", since = "1.0.0")] #![stable(feature = "rust1", since = "1.0.0")]
@ -49,38 +38,27 @@ mod tcp;
mod test; mod test;
mod udp; mod udp;
/// Possible values which can be passed to the [`shutdown`] method of /// Possible values which can be passed to the [`TcpStream::shutdown`] method.
/// [`TcpStream`].
///
/// [`shutdown`]: struct.TcpStream.html#method.shutdown
/// [`TcpStream`]: struct.TcpStream.html
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub enum Shutdown { pub enum Shutdown {
/// The reading portion of the [`TcpStream`] should be shut down. /// The reading portion of the [`TcpStream`] should be shut down.
/// ///
/// All currently blocked and future [reads] will return [`Ok(0)`]. /// All currently blocked and future [reads] will return [`Ok`]`(0)`.
/// ///
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [reads]: crate::io::Read
/// [reads]: ../../std/io/trait.Read.html
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Read, Read,
/// The writing portion of the [`TcpStream`] should be shut down. /// The writing portion of the [`TcpStream`] should be shut down.
/// ///
/// All currently blocked and future [writes] will return an error. /// All currently blocked and future [writes] will return an error.
/// ///
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [writes]: crate::io::Write
/// [writes]: ../../std/io/trait.Write.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Write, Write,
/// Both the reading and the writing portions of the [`TcpStream`] should be shut down. /// Both the reading and the writing portions of the [`TcpStream`] should be shut down.
/// ///
/// See [`Shutdown::Read`] and [`Shutdown::Write`] for more information. /// See [`Shutdown::Read`] and [`Shutdown::Write`] for more information.
///
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
/// [`Shutdown::Read`]: #variant.Read
/// [`Shutdown::Write`]: #variant.Write
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Both, Both,
} }

View File

@ -302,14 +302,6 @@ impl FromStr for SocketAddr {
/// // No problem, the `panic!` message has disappeared. /// // No problem, the `panic!` message has disappeared.
/// let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic"); /// let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic");
/// ``` /// ```
///
/// [`FromStr`]: ../../std/str/trait.FromStr.html
/// [`IpAddr`]: ../../std/net/enum.IpAddr.html
/// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html
/// [`Ipv6Addr`]: ../../std/net/struct.Ipv6Addr.html
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// [`SocketAddrV4`]: ../../std/net/struct.SocketAddrV4.html
/// [`SocketAddrV6`]: ../../std/net/struct.SocketAddrV6.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct AddrParseError(()); pub struct AddrParseError(());

View File

@ -20,13 +20,12 @@ use crate::time::Duration;
/// ///
/// The Transmission Control Protocol is specified in [IETF RFC 793]. /// The Transmission Control Protocol is specified in [IETF RFC 793].
/// ///
/// [`accept`]: ../../std/net/struct.TcpListener.html#method.accept /// [`accept`]: TcpListener::accept
/// [`connect`]: #method.connect /// [`connect`]: TcpStream::connect
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793 /// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
/// [reading]: ../../std/io/trait.Read.html /// [reading]: Read
/// [`shutdown`]: #method.shutdown /// [`shutdown`]: TcpStream::shutdown
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html /// [writing]: Write
/// [writing]: ../../std/io/trait.Write.html
/// ///
/// # Examples /// # Examples
/// ///
@ -55,11 +54,9 @@ pub struct TcpStream(net_imp::TcpStream);
/// ///
/// The Transmission Control Protocol is specified in [IETF RFC 793]. /// The Transmission Control Protocol is specified in [IETF RFC 793].
/// ///
/// [`accept`]: #method.accept /// [`accept`]: TcpListener::accept
/// [`bind`]: #method.bind /// [`bind`]: TcpListener::bind
/// [IETF RFC 793]: https://tools.ietf.org/html/rfc793 /// [IETF RFC 793]: https://tools.ietf.org/html/rfc793
/// [`Incoming`]: ../../std/net/struct.Incoming.html
/// [`TcpListener::incoming`]: #method.incoming
/// ///
/// # Examples /// # Examples
/// ///
@ -85,12 +82,10 @@ pub struct TcpListener(net_imp::TcpListener);
/// An iterator that infinitely [`accept`]s connections on a [`TcpListener`]. /// An iterator that infinitely [`accept`]s connections on a [`TcpListener`].
/// ///
/// This `struct` is created by the [`incoming`] method on [`TcpListener`]. /// This `struct` is created by the [`TcpListener::incoming`] method.
/// See its documentation for more. /// See its documentation for more.
/// ///
/// [`accept`]: ../../std/net/struct.TcpListener.html#method.accept /// [`accept`]: TcpListener::accept
/// [`incoming`]: ../../std/net/struct.TcpListener.html#method.incoming
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(Debug)] #[derive(Debug)]
pub struct Incoming<'a> { pub struct Incoming<'a> {
@ -109,8 +104,6 @@ impl TcpStream {
/// the addresses result in a successful connection, the error returned from /// the addresses result in a successful connection, the error returned from
/// the last connection attempt (the last address) is returned. /// the last connection attempt (the last address) is returned.
/// ///
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples /// # Examples
/// ///
/// Open a TCP connection to `127.0.0.1:8080`: /// Open a TCP connection to `127.0.0.1:8080`:
@ -157,8 +150,6 @@ impl TcpStream {
/// single system call. It instead calls `connect` in nonblocking mode and /// single system call. It instead calls `connect` in nonblocking mode and
/// then uses an OS-specific mechanism to await the completion of the /// then uses an OS-specific mechanism to await the completion of the
/// connection request. /// connection request.
///
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
#[stable(feature = "tcpstream_connect_timeout", since = "1.21.0")] #[stable(feature = "tcpstream_connect_timeout", since = "1.21.0")]
pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpStream> { pub fn connect_timeout(addr: &SocketAddr, timeout: Duration) -> io::Result<TcpStream> {
net_imp::TcpStream::connect_timeout(addr, timeout).map(TcpStream) net_imp::TcpStream::connect_timeout(addr, timeout).map(TcpStream)
@ -204,8 +195,6 @@ impl TcpStream {
/// portions to return immediately with an appropriate value (see the /// portions to return immediately with an appropriate value (see the
/// documentation of [`Shutdown`]). /// documentation of [`Shutdown`]).
/// ///
/// [`Shutdown`]: ../../std/net/enum.Shutdown.html
///
/// # Platform-specific behavior /// # Platform-specific behavior
/// ///
/// Calling this function multiple times may result in different behavior, /// Calling this function multiple times may result in different behavior,
@ -260,12 +249,9 @@ impl TcpStream {
/// a result of setting this option. For example Unix typically returns an /// a result of setting this option. For example Unix typically returns an
/// error of the kind [`WouldBlock`], but Windows may return [`TimedOut`]. /// error of the kind [`WouldBlock`], but Windows may return [`TimedOut`].
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`read`]: Read::read
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// [`WouldBlock`]: io::ErrorKind::WouldBlock
/// [`read`]: ../../std/io/trait.Read.html#tymethod.read /// [`TimedOut`]: io::ErrorKind::TimedOut
/// [`WouldBlock`]: ../../std/io/enum.ErrorKind.html#variant.WouldBlock
/// [`TimedOut`]: ../../std/io/enum.ErrorKind.html#variant.TimedOut
/// [`Duration`]: ../../std/time/struct.Duration.html
/// ///
/// # Examples /// # Examples
/// ///
@ -307,12 +293,9 @@ impl TcpStream {
/// as a result of setting this option. For example Unix typically returns /// as a result of setting this option. For example Unix typically returns
/// an error of the kind [`WouldBlock`], but Windows may return [`TimedOut`]. /// an error of the kind [`WouldBlock`], but Windows may return [`TimedOut`].
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`write`]: Write::write
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// [`WouldBlock`]: io::ErrorKind::WouldBlock
/// [`write`]: ../../std/io/trait.Write.html#tymethod.write /// [`TimedOut`]: io::ErrorKind::TimedOut
/// [`Duration`]: ../../std/time/struct.Duration.html
/// [`WouldBlock`]: ../../std/io/enum.ErrorKind.html#variant.WouldBlock
/// [`TimedOut`]: ../../std/io/enum.ErrorKind.html#variant.TimedOut
/// ///
/// # Examples /// # Examples
/// ///
@ -350,8 +333,7 @@ impl TcpStream {
/// ///
/// Some platforms do not provide access to the current timeout. /// Some platforms do not provide access to the current timeout.
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`read`]: Read::read
/// [`read`]: ../../std/io/trait.Read.html#tymethod.read
/// ///
/// # Examples /// # Examples
/// ///
@ -376,8 +358,7 @@ impl TcpStream {
/// ///
/// Some platforms do not provide access to the current timeout. /// Some platforms do not provide access to the current timeout.
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`write`]: Write::write
/// [`write`]: ../../std/io/trait.Write.html#tymethod.write
/// ///
/// # Examples /// # Examples
/// ///
@ -440,9 +421,7 @@ impl TcpStream {
/// Gets the value of the `TCP_NODELAY` option on this socket. /// Gets the value of the `TCP_NODELAY` option on this socket.
/// ///
/// For more information about this option, see [`set_nodelay`][link]. /// For more information about this option, see [`TcpStream::set_nodelay`].
///
/// [link]: #method.set_nodelay
/// ///
/// # Examples /// # Examples
/// ///
@ -480,9 +459,7 @@ impl TcpStream {
/// Gets the value of the `IP_TTL` option for this socket. /// Gets the value of the `IP_TTL` option for this socket.
/// ///
/// For more information about this option, see [`set_ttl`][link]. /// For more information about this option, see [`TcpStream::set_ttl`].
///
/// [link]: #method.set_ttl
/// ///
/// # Examples /// # Examples
/// ///
@ -559,8 +536,6 @@ impl TcpStream {
/// }; /// };
/// println!("bytes: {:?}", buf); /// println!("bytes: {:?}", buf);
/// ``` /// ```
///
/// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock
#[stable(feature = "net2_mutators", since = "1.9.0")] #[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
self.0.set_nonblocking(nonblocking) self.0.set_nonblocking(nonblocking)
@ -681,7 +656,7 @@ impl TcpListener {
/// ///
/// Binding with a port number of 0 will request that the OS assigns a port /// Binding with a port number of 0 will request that the OS assigns a port
/// to this listener. The port allocated can be queried via the /// to this listener. The port allocated can be queried via the
/// [`local_addr`] method. /// [`TcpListener::local_addr`] method.
/// ///
/// The address type can be any implementor of [`ToSocketAddrs`] trait. See /// The address type can be any implementor of [`ToSocketAddrs`] trait. See
/// its documentation for concrete examples. /// its documentation for concrete examples.
@ -691,9 +666,6 @@ impl TcpListener {
/// none of the addresses succeed in creating a listener, the error returned /// none of the addresses succeed in creating a listener, the error returned
/// from the last attempt (the last address) is returned. /// from the last attempt (the last address) is returned.
/// ///
/// [`local_addr`]: #method.local_addr
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples /// # Examples
/// ///
/// Creates a TCP listener bound to `127.0.0.1:80`: /// Creates a TCP listener bound to `127.0.0.1:80`:
@ -743,8 +715,6 @@ impl TcpListener {
/// object references. Both handles can be used to accept incoming /// object references. Both handles can be used to accept incoming
/// connections and options set on one listener will affect the other. /// connections and options set on one listener will affect the other.
/// ///
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
@ -764,8 +734,6 @@ impl TcpListener {
/// is established. When established, the corresponding [`TcpStream`] and the /// is established. When established, the corresponding [`TcpStream`] and the
/// remote peer's address will be returned. /// remote peer's address will be returned.
/// ///
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
@ -790,11 +758,7 @@ impl TcpListener {
/// ///
/// The returned iterator will never return [`None`] and will also not yield /// The returned iterator will never return [`None`] and will also not yield
/// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to /// the peer's [`SocketAddr`] structure. Iterating over it is equivalent to
/// calling [`accept`] in a loop. /// calling [`TcpListener::accept`] in a loop.
///
/// [`None`]: ../../std/option/enum.Option.html#variant.None
/// [`SocketAddr`]: ../../std/net/enum.SocketAddr.html
/// [`accept`]: #method.accept
/// ///
/// # Examples /// # Examples
/// ///
@ -837,9 +801,7 @@ impl TcpListener {
/// Gets the value of the `IP_TTL` option for this socket. /// Gets the value of the `IP_TTL` option for this socket.
/// ///
/// For more information about this option, see [`set_ttl`][link]. /// For more information about this option, see [`TcpListener::set_ttl`].
///
/// [link]: #method.set_ttl
/// ///
/// # Examples /// # Examples
/// ///
@ -936,8 +898,6 @@ impl TcpListener {
/// } /// }
/// } /// }
/// ``` /// ```
///
/// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock
#[stable(feature = "net2_mutators", since = "1.9.0")] #[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> { pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
self.0.set_nonblocking(nonblocking) self.0.set_nonblocking(nonblocking)

View File

@ -19,15 +19,15 @@ use crate::time::Duration;
/// an unordered, unreliable protocol; refer to [`TcpListener`] and [`TcpStream`] for TCP /// an unordered, unreliable protocol; refer to [`TcpListener`] and [`TcpStream`] for TCP
/// primitives. /// primitives.
/// ///
/// [`bind`]: #method.bind /// [`bind`]: UdpSocket::bind
/// [`connect`]: #method.connect /// [`connect`]: UdpSocket::connect
/// [IETF RFC 768]: https://tools.ietf.org/html/rfc768 /// [IETF RFC 768]: https://tools.ietf.org/html/rfc768
/// [`recv`]: #method.recv /// [`recv`]: UdpSocket::recv
/// [received from]: #method.recv_from /// [received from]: UdpSocket::recv_from
/// [`send`]: #method.send /// [`send`]: UdpSocket::send
/// [sent to]: #method.send_to /// [sent to]: UdpSocket::send_to
/// [`TcpListener`]: ../../std/net/struct.TcpListener.html /// [`TcpListener`]: crate::net::TcpListener
/// [`TcpStream`]: ../../std/net/struct.TcpStream.html /// [`TcpStream`]: crate::net::TcpStream
/// ///
/// # Examples /// # Examples
/// ///
@ -65,8 +65,6 @@ impl UdpSocket {
/// of the addresses succeed in creating a socket, the error returned from /// of the addresses succeed in creating a socket, the error returned from
/// the last attempt (the last address) is returned. /// the last attempt (the last address) is returned.
/// ///
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples /// # Examples
/// ///
/// Creates a UDP socket bound to `127.0.0.1:3400`: /// Creates a UDP socket bound to `127.0.0.1:3400`:
@ -160,8 +158,6 @@ impl UdpSocket {
/// ///
/// See issue #34202 for more details. /// See issue #34202 for more details.
/// ///
/// [`ToSocketAddrs`]: ../../std/net/trait.ToSocketAddrs.html
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
@ -193,7 +189,7 @@ impl UdpSocket {
/// ///
/// If the socket isn't connected, it will return a [`NotConnected`] error. /// If the socket isn't connected, it will return a [`NotConnected`] error.
/// ///
/// [`NotConnected`]: ../../std/io/enum.ErrorKind.html#variant.NotConnected /// [`NotConnected`]: io::ErrorKind::NotConnected
/// ///
/// ```no_run /// ```no_run
/// use std::net::UdpSocket; /// use std::net::UdpSocket;
@ -254,12 +250,9 @@ impl UdpSocket {
/// a result of setting this option. For example Unix typically returns an /// a result of setting this option. For example Unix typically returns an
/// error of the kind [`WouldBlock`], but Windows may return [`TimedOut`]. /// error of the kind [`WouldBlock`], but Windows may return [`TimedOut`].
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`read`]: io::Read::read
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// [`WouldBlock`]: io::ErrorKind::WouldBlock
/// [`read`]: ../../std/io/trait.Read.html#tymethod.read /// [`TimedOut`]: io::ErrorKind::TimedOut
/// [`Duration`]: ../../std/time/struct.Duration.html
/// [`WouldBlock`]: ../../std/io/enum.ErrorKind.html#variant.WouldBlock
/// [`TimedOut`]: ../../std/io/enum.ErrorKind.html#variant.TimedOut
/// ///
/// # Examples /// # Examples
/// ///
@ -300,12 +293,9 @@ impl UdpSocket {
/// as a result of setting this option. For example Unix typically returns /// as a result of setting this option. For example Unix typically returns
/// an error of the kind [`WouldBlock`], but Windows may return [`TimedOut`]. /// an error of the kind [`WouldBlock`], but Windows may return [`TimedOut`].
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`write`]: io::Write::write
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err /// [`WouldBlock`]: io::ErrorKind::WouldBlock
/// [`write`]: ../../std/io/trait.Write.html#tymethod.write /// [`TimedOut`]: io::ErrorKind::TimedOut
/// [`Duration`]: ../../std/time/struct.Duration.html
/// [`WouldBlock`]: ../../std/io/enum.ErrorKind.html#variant.WouldBlock
/// [`TimedOut`]: ../../std/io/enum.ErrorKind.html#variant.TimedOut
/// ///
/// # Examples /// # Examples
/// ///
@ -338,8 +328,7 @@ impl UdpSocket {
/// ///
/// If the timeout is [`None`], then [`read`] calls will block indefinitely. /// If the timeout is [`None`], then [`read`] calls will block indefinitely.
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`read`]: io::Read::read
/// [`read`]: ../../std/io/trait.Read.html#tymethod.read
/// ///
/// # Examples /// # Examples
/// ///
@ -359,8 +348,7 @@ impl UdpSocket {
/// ///
/// If the timeout is [`None`], then [`write`] calls will block indefinitely. /// If the timeout is [`None`], then [`write`] calls will block indefinitely.
/// ///
/// [`None`]: ../../std/option/enum.Option.html#variant.None /// [`write`]: io::Write::write
/// [`write`]: ../../std/io/trait.Write.html#tymethod.write
/// ///
/// # Examples /// # Examples
/// ///
@ -396,10 +384,7 @@ impl UdpSocket {
/// Gets the value of the `SO_BROADCAST` option for this socket. /// Gets the value of the `SO_BROADCAST` option for this socket.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::set_broadcast`].
/// [`set_broadcast`][link].
///
/// [link]: #method.set_broadcast
/// ///
/// # Examples /// # Examples
/// ///
@ -435,10 +420,7 @@ impl UdpSocket {
/// Gets the value of the `IP_MULTICAST_LOOP` option for this socket. /// Gets the value of the `IP_MULTICAST_LOOP` option for this socket.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::set_multicast_loop_v4`].
/// [`set_multicast_loop_v4`][link].
///
/// [link]: #method.set_multicast_loop_v4
/// ///
/// # Examples /// # Examples
/// ///
@ -477,10 +459,7 @@ impl UdpSocket {
/// Gets the value of the `IP_MULTICAST_TTL` option for this socket. /// Gets the value of the `IP_MULTICAST_TTL` option for this socket.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::set_multicast_ttl_v4`].
/// [`set_multicast_ttl_v4`][link].
///
/// [link]: #method.set_multicast_ttl_v4
/// ///
/// # Examples /// # Examples
/// ///
@ -516,10 +495,7 @@ impl UdpSocket {
/// Gets the value of the `IPV6_MULTICAST_LOOP` option for this socket. /// Gets the value of the `IPV6_MULTICAST_LOOP` option for this socket.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::set_multicast_loop_v6`].
/// [`set_multicast_loop_v6`][link].
///
/// [link]: #method.set_multicast_loop_v6
/// ///
/// # Examples /// # Examples
/// ///
@ -555,9 +531,7 @@ impl UdpSocket {
/// Gets the value of the `IP_TTL` option for this socket. /// Gets the value of the `IP_TTL` option for this socket.
/// ///
/// For more information about this option, see [`set_ttl`][link]. /// For more information about this option, see [`UdpSocket::set_ttl`].
///
/// [link]: #method.set_ttl
/// ///
/// # Examples /// # Examples
/// ///
@ -597,10 +571,7 @@ impl UdpSocket {
/// Executes an operation of the `IP_DROP_MEMBERSHIP` type. /// Executes an operation of the `IP_DROP_MEMBERSHIP` type.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::join_multicast_v4`].
/// [`join_multicast_v4`][link].
///
/// [link]: #method.join_multicast_v4
#[stable(feature = "net2_mutators", since = "1.9.0")] #[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> {
self.0.leave_multicast_v4(multiaddr, interface) self.0.leave_multicast_v4(multiaddr, interface)
@ -608,10 +579,7 @@ impl UdpSocket {
/// Executes an operation of the `IPV6_DROP_MEMBERSHIP` type. /// Executes an operation of the `IPV6_DROP_MEMBERSHIP` type.
/// ///
/// For more information about this option, see /// For more information about this option, see [`UdpSocket::join_multicast_v6`].
/// [`join_multicast_v6`][link].
///
/// [link]: #method.join_multicast_v6
#[stable(feature = "net2_mutators", since = "1.9.0")] #[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> {
self.0.leave_multicast_v6(multiaddr, interface) self.0.leave_multicast_v6(multiaddr, interface)
@ -675,11 +643,9 @@ impl UdpSocket {
/// Sends data on the socket to the remote address to which it is connected. /// Sends data on the socket to the remote address to which it is connected.
/// ///
/// The [`connect`] method will connect this socket to a remote address. This /// [`UdpSocket::connect`] will connect this socket to a remote address. This
/// method will fail if the socket is not connected. /// method will fail if the socket is not connected.
/// ///
/// [`connect`]: #method.connect
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
@ -701,11 +667,9 @@ impl UdpSocket {
/// hold the message bytes. If a message is too long to fit in the supplied buffer, /// hold the message bytes. If a message is too long to fit in the supplied buffer,
/// excess bytes may be discarded. /// excess bytes may be discarded.
/// ///
/// The [`connect`] method will connect this socket to a remote address. This /// [`UdpSocket::connect`] will connect this socket to a remote address. This
/// method will fail if the socket is not connected. /// method will fail if the socket is not connected.
/// ///
/// [`connect`]: #method.connect
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
@ -738,11 +702,9 @@ impl UdpSocket {
/// Do not use this function to implement busy waiting, instead use `libc::poll` to /// Do not use this function to implement busy waiting, instead use `libc::poll` to
/// synchronize IO events on one or more sockets. /// synchronize IO events on one or more sockets.
/// ///
/// The [`connect`] method will connect this socket to a remote address. This /// [`UdpSocket::connect`] will connect this socket to a remote address. This
/// method will fail if the socket is not connected. /// method will fail if the socket is not connected.
/// ///
/// [`connect`]: #method.connect
///
/// # Errors /// # Errors
/// ///
/// This method will fail if the socket is not connected. The `connect` method /// This method will fail if the socket is not connected. The `connect` method
@ -779,8 +741,6 @@ impl UdpSocket {
/// `FIONBIO`. On Windows calling this method corresponds to calling /// `FIONBIO`. On Windows calling this method corresponds to calling
/// `ioctlsocket` `FIONBIO`. /// `ioctlsocket` `FIONBIO`.
/// ///
/// [`io::ErrorKind::WouldBlock`]: ../io/enum.ErrorKind.html#variant.WouldBlock
///
/// # Examples /// # Examples
/// ///
/// Creates a UDP socket bound to `127.0.0.1:7878` and read bytes in /// Creates a UDP socket bound to `127.0.0.1:7878` and read bytes in