Remove all unstable deprecated functionality
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
This commit is contained in:
parent
d07d465cf6
commit
8d90d3f368
125 changed files with 1681 additions and 15526 deletions
|
@ -186,42 +186,6 @@ impl TcpStream {
|
|||
|
||||
pub fn into_socket(self) -> Socket { self.inner }
|
||||
|
||||
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_NODELAY,
|
||||
nodelay as c_int)
|
||||
}
|
||||
|
||||
pub fn set_keepalive(&self, seconds: Option<u32>) -> io::Result<()> {
|
||||
let ret = setsockopt(&self.inner, libc::SOL_SOCKET, libc::SO_KEEPALIVE,
|
||||
seconds.is_some() as c_int);
|
||||
match seconds {
|
||||
Some(n) => ret.and_then(|()| self.set_tcp_keepalive(n)),
|
||||
None => ret,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
|
||||
seconds as c_int)
|
||||
}
|
||||
#[cfg(any(target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "linux"))]
|
||||
fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
|
||||
seconds as c_int)
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "linux")))]
|
||||
fn set_tcp_keepalive(&self, _seconds: u32) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_read_timeout(&self, dur: Option<Duration>) -> io::Result<()> {
|
||||
self.inner.set_timeout(dur, libc::SO_RCVTIMEO)
|
||||
}
|
||||
|
@ -431,65 +395,6 @@ impl UdpSocket {
|
|||
Ok(ret as usize)
|
||||
}
|
||||
|
||||
pub fn set_broadcast(&self, on: bool) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::SOL_SOCKET, libc::SO_BROADCAST,
|
||||
on as c_int)
|
||||
}
|
||||
|
||||
pub fn set_multicast_loop(&self, on: bool) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_IP,
|
||||
libc::IP_MULTICAST_LOOP, on as c_int)
|
||||
}
|
||||
|
||||
pub fn join_multicast(&self, multi: &IpAddr) -> io::Result<()> {
|
||||
match *multi {
|
||||
IpAddr::V4(..) => {
|
||||
self.set_membership(multi, libc::IP_ADD_MEMBERSHIP)
|
||||
}
|
||||
IpAddr::V6(..) => {
|
||||
self.set_membership(multi, libc::IPV6_ADD_MEMBERSHIP)
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn leave_multicast(&self, multi: &IpAddr) -> io::Result<()> {
|
||||
match *multi {
|
||||
IpAddr::V4(..) => {
|
||||
self.set_membership(multi, libc::IP_DROP_MEMBERSHIP)
|
||||
}
|
||||
IpAddr::V6(..) => {
|
||||
self.set_membership(multi, libc::IPV6_DROP_MEMBERSHIP)
|
||||
}
|
||||
}
|
||||
}
|
||||
fn set_membership(&self, addr: &IpAddr, opt: c_int) -> io::Result<()> {
|
||||
match *addr {
|
||||
IpAddr::V4(ref addr) => {
|
||||
let mreq = libc::ip_mreq {
|
||||
imr_multiaddr: *addr.as_inner(),
|
||||
// interface == INADDR_ANY
|
||||
imr_interface: libc::in_addr { s_addr: 0x0 },
|
||||
};
|
||||
setsockopt(&self.inner, libc::IPPROTO_IP, opt, mreq)
|
||||
}
|
||||
IpAddr::V6(ref addr) => {
|
||||
let mreq = libc::ip6_mreq {
|
||||
ipv6mr_multiaddr: *addr.as_inner(),
|
||||
ipv6mr_interface: 0,
|
||||
};
|
||||
setsockopt(&self.inner, libc::IPPROTO_IPV6, opt, mreq)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn multicast_time_to_live(&self, ttl: i32) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_IP, libc::IP_MULTICAST_TTL,
|
||||
ttl as c_int)
|
||||
}
|
||||
|
||||
pub fn time_to_live(&self, ttl: i32) -> io::Result<()> {
|
||||
setsockopt(&self.inner, libc::IPPROTO_IP, libc::IP_TTL, ttl as c_int)
|
||||
}
|
||||
|
||||
pub fn duplicate(&self) -> io::Result<UdpSocket> {
|
||||
self.inner.duplicate().map(|s| UdpSocket { inner: s })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue