Skip to content

Commit 6a6ab3f

Browse files
committed
---
yaml --- r: 274791 b: refs/heads/stable c: 3de820e h: refs/heads/master i: 274789: 3ed5e17 274787: 8ed8811 274783: ee6d7fc
1 parent 46c9159 commit 6a6ab3f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 5a249abba720b58bbbd23e8b0f532bd7a6ea61de
32+
refs/heads/stable: 3de820ee7912f46761ca4f0c50f67164aaa5f42f
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libstd/net/addr.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,22 @@ impl SocketAddrV6 {
175175
#[stable(feature = "rust1", since = "1.0.0")]
176176
pub fn flowinfo(&self) -> u32 { ntoh(self.inner.sin6_flowinfo) }
177177

178+
/// Change the flow information associated with this socket address.
179+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
180+
pub fn set_flowinfo(&mut self, new_flowinfo: u32) {
181+
self.inner.sin6_flowinfo = hton(new_flowinfo)
182+
}
183+
178184
/// Returns the scope ID associated with this address,
179185
/// corresponding to the `sin6_scope_id` field in C.
180186
#[stable(feature = "rust1", since = "1.0.0")]
181187
pub fn scope_id(&self) -> u32 { ntoh(self.inner.sin6_scope_id) }
188+
189+
/// Change the scope ID associated with this socket address.
190+
#[unstable(feature = "sockaddr_setters", reason = "recent addition", issue = "31572")]
191+
pub fn set_scope_id(&mut self, new_scope_id: u32) {
192+
self.inner.sin6_scope_id = hton(new_scope_id)
193+
}
182194
}
183195

184196
impl FromInner<c::sockaddr_in> for SocketAddrV4 {
@@ -593,4 +605,20 @@ mod tests {
593605
addr.set_port(8080);
594606
assert_eq!(addr.port(), 8080);
595607
}
608+
609+
#[test]
610+
fn set_flowinfo() {
611+
let mut v6 = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 80, 10, 0);
612+
assert_eq!(v6.flowinfo(), 10);
613+
v6.set_flowinfo(20);
614+
assert_eq!(v6.flowinfo(), 20);
615+
}
616+
617+
#[test]
618+
fn set_scope_id() {
619+
let mut v6 = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 80, 0, 10);
620+
assert_eq!(v6.scope_id(), 10);
621+
v6.set_scope_id(20);
622+
assert_eq!(v6.scope_id(), 20);
623+
}
596624
}

0 commit comments

Comments
 (0)