diff options
| author | bors <bors@rust-lang.org> | 2015-07-20 18:12:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-07-20 18:12:40 +0000 |
| commit | 47265bbf37385a087235a8c5eddea5944ae6465e (patch) | |
| tree | dc96dab725a1268bab3682ac0c77b74e9a06a49f /src/libstd/sys/common | |
| parent | 18557500cb91596f3614d4cf65439f8c5f47b2e0 (diff) | |
| parent | 7e9e3896dfcef4852ca8ad90f91baf5187b0248e (diff) | |
| download | rust-47265bbf37385a087235a8c5eddea5944ae6465e.tar.gz rust-47265bbf37385a087235a8c5eddea5944ae6465e.zip | |
Auto merge of #27064 - alexcrichton:into-raw-os, r=brson
This commit is an implementation of [RFC 1174][rfc] which adds three new traits to the standard library: * `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc) * `IntoRawHandle` - implemented on Windows for files, processes, etc * `IntoRawSocket` - implemented on Windows for networking types [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md Closes #27062
Diffstat (limited to 'src/libstd/sys/common')
| -rw-r--r-- | src/libstd/sys/common/net.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 5890e6a7889..6dd222b8f6e 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -184,6 +184,8 @@ impl TcpStream { pub fn socket(&self) -> &Socket { &self.inner } + 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) @@ -336,6 +338,8 @@ impl TcpListener { pub fn socket(&self) -> &Socket { &self.inner } + pub fn into_socket(self) -> Socket { self.inner } + pub fn socket_addr(&self) -> io::Result<SocketAddr> { sockname(|buf, len| unsafe { libc::getsockname(*self.inner.as_inner(), buf, len) @@ -396,6 +400,8 @@ impl UdpSocket { pub fn socket(&self) -> &Socket { &self.inner } + pub fn into_socket(self) -> Socket { self.inner } + pub fn socket_addr(&self) -> io::Result<SocketAddr> { sockname(|buf, len| unsafe { libc::getsockname(*self.inner.as_inner(), buf, len) |
