@@ -60,7 +60,7 @@ pub enum Ipv6MulticastScope {
60
60
impl Ipv4Addr {
61
61
/// Creates a new IPv4 address from four eight-bit octets.
62
62
///
63
- /// The result will represent the IP address a.b.c.d
63
+ /// The result will represent the IP address `a`.`b`.`c`.`d`.
64
64
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
65
65
pub fn new ( a : u8 , b : u8 , c : u8 , d : u8 ) -> Ipv4Addr {
66
66
Ipv4Addr {
@@ -73,19 +73,19 @@ impl Ipv4Addr {
73
73
}
74
74
}
75
75
76
- /// Returns the four eight-bit integers that make up this address
76
+ /// Returns the four eight-bit integers that make up this address.
77
77
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
78
78
pub fn octets ( & self ) -> [ u8 ; 4 ] {
79
79
let bits = ntoh ( self . inner . s_addr ) ;
80
80
[ ( bits >> 24 ) as u8 , ( bits >> 16 ) as u8 , ( bits >> 8 ) as u8 , bits as u8 ]
81
81
}
82
82
83
- /// Returns true for the special 'unspecified' address 0.0.0.0
83
+ /// Returns true for the special 'unspecified' address 0.0.0.0.
84
84
pub fn is_unspecified ( & self ) -> bool {
85
85
self . inner . s_addr == 0
86
86
}
87
87
88
- /// Returns true if this is a loopback address (127.0.0.0/8)
88
+ /// Returns true if this is a loopback address (127.0.0.0/8).
89
89
pub fn is_loopback ( & self ) -> bool {
90
90
self . octets ( ) [ 0 ] == 127
91
91
}
@@ -106,7 +106,7 @@ impl Ipv4Addr {
106
106
}
107
107
}
108
108
109
- /// Returns true if the address is link-local (169.254.0.0/16)
109
+ /// Returns true if the address is link-local (169.254.0.0/16).
110
110
pub fn is_link_local ( & self ) -> bool {
111
111
self . octets ( ) [ 0 ] == 169 && self . octets ( ) [ 1 ] == 254
112
112
}
@@ -116,7 +116,7 @@ impl Ipv4Addr {
116
116
/// Non-globally-routable networks include the private networks (10.0.0.0/8,
117
117
/// 172.16.0.0/12 and 192.168.0.0/16), the loopback network (127.0.0.0/8),
118
118
/// the link-local network (169.254.0.0/16), the broadcast address (255.255.255.255/32) and
119
- /// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24)
119
+ /// the test networks used for documentation (192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24).
120
120
pub fn is_global ( & self ) -> bool {
121
121
!self . is_private ( ) && !self . is_loopback ( ) && !self . is_link_local ( ) &&
122
122
!self . is_broadcast ( ) && !self . is_documentation ( )
@@ -131,13 +131,13 @@ impl Ipv4Addr {
131
131
132
132
/// Returns true if this is a broadcast address.
133
133
///
134
- /// A broadcast address has all octets set to 255 as defined in RFC 919
134
+ /// A broadcast address has all octets set to 255 as defined in RFC 919.
135
135
pub fn is_broadcast ( & self ) -> bool {
136
136
self . octets ( ) [ 0 ] == 255 && self . octets ( ) [ 1 ] == 255 &&
137
137
self . octets ( ) [ 2 ] == 255 && self . octets ( ) [ 3 ] == 255
138
138
}
139
139
140
- /// Returns true if this address is in a range designated for documentation
140
+ /// Returns true if this address is in a range designated for documentation.
141
141
///
142
142
/// This is defined in RFC 5737
143
143
/// - 192.0.2.0/24 (TEST-NET-1)
@@ -152,7 +152,7 @@ impl Ipv4Addr {
152
152
}
153
153
}
154
154
155
- /// Converts this address to an IPv4-compatible IPv6 address
155
+ /// Converts this address to an IPv4-compatible IPv6 address.
156
156
///
157
157
/// a.b.c.d becomes ::a.b.c.d
158
158
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -162,7 +162,7 @@ impl Ipv4Addr {
162
162
( ( self . octets ( ) [ 2 ] as u16 ) << 8 ) | self . octets ( ) [ 3 ] as u16 )
163
163
}
164
164
165
- /// Converts this address to an IPv4-mapped IPv6 address
165
+ /// Converts this address to an IPv4-mapped IPv6 address.
166
166
///
167
167
/// a.b.c.d becomes ::ffff:a.b.c.d
168
168
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -247,7 +247,7 @@ impl FromInner<libc::in_addr> for Ipv4Addr {
247
247
impl Ipv6Addr {
248
248
/// Creates a new IPv6 address from eight 16-bit segments.
249
249
///
250
- /// The result will represent the IP address a:b:c:d:e:f:g:h
250
+ /// The result will represent the IP address a:b:c:d:e:f:g:h.
251
251
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
252
252
pub fn new ( a : u16 , b : u16 , c : u16 , d : u16 , e : u16 , f : u16 , g : u16 ,
253
253
h : u16 ) -> Ipv6Addr {
@@ -259,7 +259,7 @@ impl Ipv6Addr {
259
259
}
260
260
}
261
261
262
- /// Returns the eight 16-bit segments that make up this address
262
+ /// Returns the eight 16-bit segments that make up this address.
263
263
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
264
264
pub fn segments ( & self ) -> [ u16 ; 8 ] {
265
265
[ ntoh ( self . inner . s6_addr [ 0 ] ) ,
@@ -272,12 +272,12 @@ impl Ipv6Addr {
272
272
ntoh ( self . inner . s6_addr [ 7 ] ) ]
273
273
}
274
274
275
- /// Returns true for the special 'unspecified' address ::
275
+ /// Returns true for the special 'unspecified' address ::.
276
276
pub fn is_unspecified ( & self ) -> bool {
277
277
self . segments ( ) == [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
278
278
}
279
279
280
- /// Returns true if this is a loopback address (::1)
280
+ /// Returns true if this is a loopback address (::1).
281
281
pub fn is_loopback ( & self ) -> bool {
282
282
self . segments ( ) == [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ]
283
283
}
@@ -295,25 +295,25 @@ impl Ipv6Addr {
295
295
}
296
296
}
297
297
298
- /// Returns true if this is a unique local address (IPv6)
298
+ /// Returns true if this is a unique local address (IPv6).
299
299
///
300
- /// Unique local addresses are defined in RFC4193 and have the form fc00::/7
300
+ /// Unique local addresses are defined in RFC4193 and have the form fc00::/7.
301
301
pub fn is_unique_local ( & self ) -> bool {
302
302
( self . segments ( ) [ 0 ] & 0xfe00 ) == 0xfc00
303
303
}
304
304
305
- /// Returns true if the address is unicast and link-local (fe80::/10)
305
+ /// Returns true if the address is unicast and link-local (fe80::/10).
306
306
pub fn is_unicast_link_local ( & self ) -> bool {
307
307
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfe80
308
308
}
309
309
310
310
/// Returns true if this is a deprecated unicast site-local address (IPv6
311
- /// fec0::/10)
311
+ /// fec0::/10).
312
312
pub fn is_unicast_site_local ( & self ) -> bool {
313
313
( self . segments ( ) [ 0 ] & 0xffc0 ) == 0xfec0
314
314
}
315
315
316
- /// Returns true if the address is a globally routable unicast address
316
+ /// Returns true if the address is a globally routable unicast address.
317
317
///
318
318
/// Non-globally-routable unicast addresses include the loopback address,
319
319
/// the link-local addresses, the deprecated site-local addresses and the
0 commit comments