@@ -82,22 +82,24 @@ impl Ipv4Addr {
82
82
[ ( bits >> 24 ) as u8 , ( bits >> 16 ) as u8 , ( bits >> 8 ) as u8 , bits as u8 ]
83
83
}
84
84
85
- /// Returns true for the special 'unspecified' address 0.0.0.0.
85
+ /// Returns true for the special 'unspecified' address ( 0.0.0.0) .
86
86
pub fn is_unspecified ( & self ) -> bool {
87
87
self . inner . s_addr == 0
88
88
}
89
89
90
90
/// Returns true if this is a loopback address (127.0.0.0/8).
91
91
///
92
- /// This property is defined by RFC 6890.
92
+ /// This property is defined by [RFC 1122].
93
+ /// [RFC 1122]: https://tools.ietf.org/html/rfc1122
93
94
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
94
95
pub fn is_loopback ( & self ) -> bool {
95
96
self . octets ( ) [ 0 ] == 127
96
97
}
97
98
98
99
/// Returns true if this is a private address.
99
100
///
100
- /// The private address ranges are defined in RFC 1918 and include:
101
+ /// The private address ranges are defined in [RFC 1918] and include:
102
+ /// [RFC 1918]: https://tools.ietf.org/html/rfc1918
101
103
///
102
104
/// - 10.0.0.0/8
103
105
/// - 172.16.0.0/12
@@ -114,7 +116,8 @@ impl Ipv4Addr {
114
116
115
117
/// Returns true if the address is link-local (169.254.0.0/16).
116
118
///
117
- /// This property is defined by RFC 6890.
119
+ /// This property is defined by [RFC 3927].
120
+ /// [RFC 3927]: https://tools.ietf.org/html/rfc3927
118
121
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
119
122
pub fn is_link_local ( & self ) -> bool {
120
123
self . octets ( ) [ 0 ] == 169 && self . octets ( ) [ 1 ] == 254
@@ -137,18 +140,20 @@ impl Ipv4Addr {
137
140
!self . is_broadcast ( ) && !self . is_documentation ( ) && !self . is_unspecified ( )
138
141
}
139
142
140
- /// Returns true if this is a multicast address.
143
+ /// Returns true if this is a multicast address (224.0.0.0/4) .
141
144
///
142
145
/// Multicast addresses have a most significant octet between 224 and 239,
143
- /// and is defined by RFC 5771.
146
+ /// and is defined by [RFC 5771].
147
+ /// [RFC 5771]: https://tools.ietf.org/html/rfc5771
144
148
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
145
149
pub fn is_multicast ( & self ) -> bool {
146
150
self . octets ( ) [ 0 ] >= 224 && self . octets ( ) [ 0 ] <= 239
147
151
}
148
152
149
- /// Returns true if this is a broadcast address.
153
+ /// Returns true if this is a broadcast address (255.255.255.255) .
150
154
///
151
- /// A broadcast address has all octets set to 255 as defined in RFC 919.
155
+ /// A broadcast address has all octets set to 255 as defined in [RFC 919].
156
+ /// [RFC 919]: https://tools.ietf.org/html/rfc919
152
157
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
153
158
pub fn is_broadcast ( & self ) -> bool {
154
159
self . octets ( ) [ 0 ] == 255 && self . octets ( ) [ 1 ] == 255 &&
@@ -157,7 +162,8 @@ impl Ipv4Addr {
157
162
158
163
/// Returns true if this address is in a range designated for documentation.
159
164
///
160
- /// This is defined in RFC 5737:
165
+ /// This is defined in [RFC 5737]:
166
+ /// [RFC 5737]: https://tools.ietf.org/html/rfc5737
161
167
///
162
168
/// - 192.0.2.0/24 (TEST-NET-1)
163
169
/// - 198.51.100.0/24 (TEST-NET-2)
@@ -321,17 +327,19 @@ impl Ipv6Addr {
321
327
]
322
328
}
323
329
324
- /// Returns true for the special 'unspecified' address :: .
330
+ /// Returns true for the special 'unspecified' address (::) .
325
331
///
326
- /// This property is defined in RFC 6890.
332
+ /// This property is defined in [RFC 4291].
333
+ /// [RFC 4291]: https://tools.ietf.org/html/rfc4291
327
334
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
328
335
pub fn is_unspecified ( & self ) -> bool {
329
336
self . segments ( ) == [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
330
337
}
331
338
332
339
/// Returns true if this is a loopback address (::1).
333
340
///
334
- /// This property is defined in RFC 6890.
341
+ /// This property is defined in [RFC 4291].
342
+ /// [RFC 4291]: https://tools.ietf.org/html/rfc4291
335
343
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
336
344
pub fn is_loopback ( & self ) -> bool {
337
345
self . segments ( ) == [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ]
@@ -352,26 +360,33 @@ impl Ipv6Addr {
352
360
}
353
361
}
354
362
355
- /// Returns true if this is a unique local address (IPv6 ).
363
+ /// Returns true if this is a unique local address (fc00::/7 ).
356
364
///
357
- /// Unique local addresses are defined in RFC 4193 and have the form fc00::/7.
365
+ /// This property is defined in [RFC 4193].
366
+ /// [RFC 4193]: https://tools.ietf.org/html/rfc4193
358
367
pub fn is_unique_local ( & self ) -> bool {
359
368
( self . segments ( ) [ 0 ] & 0xfe00 ) == 0xfc00
360
369
}
361
370
362
371
/// Returns true if the address is unicast and link-local (fe80::/10).
372
+ ///
373
+ /// This property is defined in [RFC 4291].
374
+ /// [RFC 4291]: https://tools.ietf.org/html/rfc4291
363
375
pub fn is_unicast_link_local ( & self ) -> bool {
364
376
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfe80
365
377
}
366
378
367
- /// Returns true if this is a deprecated unicast site-local address (IPv6
368
- /// fec0::/10).
379
+ /// Returns true if this is a deprecated unicast site-local address
380
+ /// ( fec0::/10).
369
381
pub fn is_unicast_site_local ( & self ) -> bool {
370
382
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfec0
371
383
}
372
384
373
385
/// Returns true if this is an address reserved for documentation
374
- /// This is defined to be 2001:db8::/32 in RFC 3849.
386
+ /// (2001:db8::/32).
387
+ ///
388
+ /// This property is defined in [RFC 3849].
389
+ /// [RFC 3849]: https://tools.ietf.org/html/rfc3849
375
390
pub fn is_documentation ( & self ) -> bool {
376
391
( self . segments ( ) [ 0 ] == 0x2001 ) && ( self . segments ( ) [ 1 ] == 0xdb8 )
377
392
}
@@ -411,10 +426,10 @@ impl Ipv6Addr {
411
426
}
412
427
}
413
428
414
- /// Returns true if this is a multicast address.
429
+ /// Returns true if this is a multicast address (ff00::/8) .
415
430
///
416
- /// Multicast addresses have the form ff00::/8, and this property is defined
417
- /// by RFC 3956.
431
+ /// This property is defined by [RFC 4291].
432
+ /// [ RFC 4291]: https://tools.ietf.org/html/rfc4291
418
433
#[ stable( since = "1.7.0" , feature = "ip_17" ) ]
419
434
pub fn is_multicast ( & self ) -> bool {
420
435
( self . segments ( ) [ 0 ] & 0xff00 ) == 0xff00
0 commit comments