Skip to content

Commit a674ae6

Browse files
committed
Add documentation for Ipv6MulticastScope
1 parent 798baeb commit a674ae6

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

library/std/src/net/ip.rs

+43-1
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,58 @@ pub struct Ipv6Addr {
116116
inner: c::in6_addr,
117117
}
118118

119-
#[allow(missing_docs)]
119+
/// Scope of an [IPv6 multicast address] as defined in [IETF RFC 7346 section 2].
120+
///
121+
/// # Stability Guarantees
122+
///
123+
/// Not all possible values for a multicast scope have been assigned.
124+
/// Future RFCs may introduce new scopes, which will be added as variants to this enum;
125+
/// because of this the enum is marked as `#[non_exhaustive]`.
126+
///
127+
/// # Examples
128+
/// ```
129+
/// #![feature(ip)]
130+
///
131+
/// use std::net::Ipv6Addr;
132+
/// use std::net::Ipv6MulticastScope::*;
133+
///
134+
/// // An IPv6 multicast address with global scope (`ff0e::`).
135+
/// let address = Ipv6Addr::new(0xff0e, 0, 0, 0, 0, 0, 0, 0);
136+
///
137+
/// // Will print "Global scope".
138+
/// match address.multicast_scope() {
139+
/// Some(InterfaceLocal) => println!("Interface-Local scope"),
140+
/// Some(LinkLocal) => println!("Link-Local scope"),
141+
/// Some(RealmLocal) => println!("Realm-Local scope"),
142+
/// Some(AdminLocal) => println!("Admin-Local scope"),
143+
/// Some(SiteLocal) => println!("Site-Local scope"),
144+
/// Some(OrganizationLocal) => println!("Organization-Local scope"),
145+
/// Some(Global) => println!("Global scope"),
146+
/// Some(_) => println!("Unknown scope"),
147+
/// None => println!("Not a multicast address!")
148+
/// }
149+
///
150+
/// ```
151+
///
152+
/// [IPv6 multicast address]: Ipv6Addr
153+
/// [IETF RFC 7346 section 2]: https://tools.ietf.org/html/rfc7346#section-2
120154
#[derive(Copy, PartialEq, Eq, Clone, Hash, Debug)]
121155
#[unstable(feature = "ip", issue = "27709")]
156+
#[non_exhaustive]
122157
pub enum Ipv6MulticastScope {
158+
/// Interface-Local scope.
123159
InterfaceLocal,
160+
/// Link-Local scope.
124161
LinkLocal,
162+
/// Realm-Local scope.
125163
RealmLocal,
164+
/// Admin-Local scope.
126165
AdminLocal,
166+
/// Site-Local scope.
127167
SiteLocal,
168+
/// Organization-Local scope.
128169
OrganizationLocal,
170+
/// Global scope.
129171
Global,
130172
}
131173

0 commit comments

Comments
 (0)