mirror of
https://github.com/openharmony/third_party_rust_io-lifetimes.git
synced 2026-07-01 21:04:05 -04:00
Add From<OwnedFd> and From<T> for OwnedFd impls.
The std implementation uses `From` impls instead of `FromFd`/`IntoFd`. io-lifetimes continues to support `FromFd`/`IntoFd` so that it can add impls for third-party types. But for users who don't need that, add the same `From` impls that std has.
This commit is contained in:
@@ -41,6 +41,15 @@ impl IntoFd for Thing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(io_lifetimes_use_std))]
|
||||
#[cfg(not(windows))]
|
||||
impl From<Thing> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: Thing) -> Self {
|
||||
owned.filelike
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
impl FromFd for Thing {
|
||||
#[inline]
|
||||
@@ -49,6 +58,15 @@ impl FromFd for Thing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(io_lifetimes_use_std))]
|
||||
#[cfg(not(windows))]
|
||||
impl From<OwnedFd> for Thing {
|
||||
#[inline]
|
||||
fn from(filelike: OwnedFd) -> Self {
|
||||
Self { filelike }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl AsHandle for Thing {
|
||||
#[inline]
|
||||
@@ -65,6 +83,15 @@ impl IntoHandle for Thing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(io_lifetimes_use_std))]
|
||||
#[cfg(windows)]
|
||||
impl From<Thing> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: Thing) -> Self {
|
||||
owned.filelike
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for Thing {
|
||||
#[inline]
|
||||
@@ -73,6 +100,15 @@ impl FromHandle for Thing {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(io_lifetimes_use_std))]
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for Thing {
|
||||
#[inline]
|
||||
fn from(filelike: OwnedHandle) -> Self {
|
||||
Self { filelike }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "close")]
|
||||
fn main() {
|
||||
use io_lifetimes::{AsFilelike, FromFilelike, IntoFilelike};
|
||||
|
||||
@@ -45,6 +45,14 @@ impl IntoFd for async_std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<async_std::fs::File> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::fs::File) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for async_std::fs::File {
|
||||
#[inline]
|
||||
@@ -53,6 +61,14 @@ impl IntoHandle for async_std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<async_std::fs::File> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: async_std::fs::File) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for async_std::fs::File {
|
||||
#[inline]
|
||||
@@ -61,6 +77,14 @@ impl FromFd for async_std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for async_std::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for async_std::fs::File {
|
||||
#[inline]
|
||||
@@ -69,6 +93,14 @@ impl FromHandle for async_std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for async_std::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SocketlikeViewType for async_std::net::TcpStream {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -95,6 +127,14 @@ impl IntoFd for async_std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<async_std::net::TcpStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for async_std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -103,6 +143,14 @@ impl IntoSocket for async_std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<async_std::net::TcpStream> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for async_std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -111,6 +159,14 @@ impl FromFd for async_std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for async_std::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for async_std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -119,6 +175,14 @@ impl FromSocket for async_std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for async_std::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SocketlikeViewType for async_std::net::TcpListener {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -145,6 +209,14 @@ impl IntoFd for async_std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<async_std::net::TcpListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for async_std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -153,6 +225,14 @@ impl IntoSocket for async_std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<async_std::net::TcpListener> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for async_std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -161,6 +241,14 @@ impl FromFd for async_std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for async_std::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for async_std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -169,6 +257,14 @@ impl FromSocket for async_std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for async_std::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SocketlikeViewType for async_std::net::UdpSocket {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -195,6 +291,14 @@ impl IntoFd for async_std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<async_std::net::UdpSocket> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for async_std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -203,6 +307,14 @@ impl IntoSocket for async_std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<async_std::net::UdpSocket> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: async_std::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for async_std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -211,6 +323,14 @@ impl FromFd for async_std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for async_std::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for async_std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -219,6 +339,14 @@ impl FromSocket for async_std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for async_std::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for async_std::io::Stdin {
|
||||
#[inline]
|
||||
@@ -286,6 +414,14 @@ impl IntoFd for async_std::os::unix::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<async_std::os::unix::net::UnixStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::os::unix::net::UnixStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for async_std::os::unix::net::UnixStream {
|
||||
#[inline]
|
||||
@@ -294,6 +430,14 @@ impl FromFd for async_std::os::unix::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for async_std::os::unix::net::UnixStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixListener {}
|
||||
|
||||
@@ -313,6 +457,14 @@ impl IntoFd for async_std::os::unix::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<async_std::os::unix::net::UnixListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::os::unix::net::UnixListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for async_std::os::unix::net::UnixListener {
|
||||
#[inline]
|
||||
@@ -321,6 +473,14 @@ impl FromFd for async_std::os::unix::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for async_std::os::unix::net::UnixListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixDatagram {}
|
||||
|
||||
@@ -340,6 +500,14 @@ impl IntoFd for async_std::os::unix::net::UnixDatagram {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<async_std::os::unix::net::UnixDatagram> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: async_std::os::unix::net::UnixDatagram) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for async_std::os::unix::net::UnixDatagram {
|
||||
#[inline]
|
||||
@@ -347,3 +515,11 @@ impl FromFd for async_std::os::unix::net::UnixDatagram {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for async_std::os::unix::net::UnixDatagram {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,14 @@ impl IntoFd for fs_err::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<fs_err::File> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: fs_err::File) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for fs_err::File {
|
||||
#[inline]
|
||||
@@ -44,3 +52,11 @@ impl IntoHandle for fs_err::File {
|
||||
unsafe { OwnedHandle::from_raw_handle(self.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<fs_err::File> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: fs_err::File) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ impl IntoFd for mio::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<mio::net::TcpStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for mio::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -50,6 +58,14 @@ impl IntoSocket for mio::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<mio::net::TcpStream> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for mio::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -58,6 +74,14 @@ impl FromFd for mio::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for mio::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for mio::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -66,6 +90,14 @@ impl FromSocket for mio::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for mio::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SocketlikeViewType for mio::net::TcpListener {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -92,6 +124,14 @@ impl IntoFd for mio::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<mio::net::TcpListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for mio::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -100,6 +140,14 @@ impl IntoSocket for mio::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<mio::net::TcpListener> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for mio::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -108,6 +156,14 @@ impl FromFd for mio::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for mio::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for mio::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -116,6 +172,14 @@ impl FromSocket for mio::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for mio::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl SocketlikeViewType for mio::net::UdpSocket {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -142,6 +206,14 @@ impl IntoFd for mio::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<mio::net::UdpSocket> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for mio::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -150,6 +222,14 @@ impl IntoSocket for mio::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<mio::net::UdpSocket> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for mio::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -158,6 +238,14 @@ impl FromFd for mio::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for mio::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for mio::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -166,6 +254,14 @@ impl FromSocket for mio::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for mio::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl SocketlikeViewType for mio::net::UnixDatagram {}
|
||||
|
||||
@@ -185,6 +281,14 @@ impl IntoFd for mio::net::UnixDatagram {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<mio::net::UnixDatagram> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::UnixDatagram) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for mio::net::UnixDatagram {
|
||||
#[inline]
|
||||
@@ -193,6 +297,14 @@ impl FromFd for mio::net::UnixDatagram {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for mio::net::UnixDatagram {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl SocketlikeViewType for mio::net::UnixListener {}
|
||||
|
||||
@@ -212,6 +324,14 @@ impl IntoFd for mio::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<mio::net::UnixListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::UnixListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for mio::net::UnixListener {
|
||||
#[inline]
|
||||
@@ -220,6 +340,14 @@ impl FromFd for mio::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for mio::net::UnixListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl SocketlikeViewType for mio::net::UnixStream {}
|
||||
|
||||
@@ -239,6 +367,14 @@ impl IntoFd for mio::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<mio::net::UnixStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::net::UnixStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for mio::net::UnixStream {
|
||||
#[inline]
|
||||
@@ -247,6 +383,14 @@ impl FromFd for mio::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for mio::net::UnixStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl FilelikeViewType for mio::unix::pipe::Receiver {}
|
||||
|
||||
@@ -266,6 +410,14 @@ impl IntoFd for mio::unix::pipe::Receiver {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<mio::unix::pipe::Receiver> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::unix::pipe::Receiver) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for mio::unix::pipe::Receiver {
|
||||
#[inline]
|
||||
@@ -274,6 +426,14 @@ impl FromFd for mio::unix::pipe::Receiver {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for mio::unix::pipe::Receiver {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
unsafe impl FilelikeViewType for mio::unix::pipe::Sender {}
|
||||
|
||||
@@ -293,6 +453,14 @@ impl IntoFd for mio::unix::pipe::Sender {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<mio::unix::pipe::Sender> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: mio::unix::pipe::Sender) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for mio::unix::pipe::Sender {
|
||||
#[inline]
|
||||
@@ -300,3 +468,11 @@ impl FromFd for mio::unix::pipe::Sender {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for mio::unix::pipe::Sender {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,14 @@ impl IntoFd for os_pipe::PipeReader {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<os_pipe::PipeReader> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: os_pipe::PipeReader) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for os_pipe::PipeReader {
|
||||
#[inline]
|
||||
@@ -48,6 +56,14 @@ impl IntoHandle for os_pipe::PipeReader {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<os_pipe::PipeReader> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: os_pipe::PipeReader) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for os_pipe::PipeReader {
|
||||
#[inline]
|
||||
@@ -56,6 +72,14 @@ impl FromFd for os_pipe::PipeReader {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for os_pipe::PipeReader {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for os_pipe::PipeReader {
|
||||
#[inline]
|
||||
@@ -64,6 +88,14 @@ impl FromHandle for os_pipe::PipeReader {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for os_pipe::PipeReader {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl FilelikeViewType for os_pipe::PipeWriter {}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
@@ -90,6 +122,14 @@ impl IntoFd for os_pipe::PipeWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<os_pipe::PipeWriter> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: os_pipe::PipeWriter) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for os_pipe::PipeWriter {
|
||||
#[inline]
|
||||
@@ -98,6 +138,14 @@ impl IntoHandle for os_pipe::PipeWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<os_pipe::PipeWriter> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: os_pipe::PipeWriter) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for os_pipe::PipeWriter {
|
||||
#[inline]
|
||||
@@ -106,6 +154,14 @@ impl FromFd for os_pipe::PipeWriter {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for os_pipe::PipeWriter {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for os_pipe::PipeWriter {
|
||||
#[inline]
|
||||
@@ -113,3 +169,11 @@ impl FromHandle for os_pipe::PipeWriter {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for os_pipe::PipeWriter {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,14 @@ impl IntoFd for socket2::Socket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<socket2::Socket> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: socket2::Socket) -> Self {
|
||||
unsafe { OwnedFd::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for socket2::Socket {
|
||||
#[inline]
|
||||
@@ -48,6 +56,14 @@ impl IntoSocket for socket2::Socket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<socket2::Socket> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: socket2::Socket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for socket2::Socket {
|
||||
#[inline]
|
||||
@@ -56,6 +72,14 @@ impl FromFd for socket2::Socket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for socket2::Socket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for socket2::Socket {
|
||||
#[inline]
|
||||
@@ -63,3 +87,11 @@ impl FromSocket for socket2::Socket {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for socket2::Socket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +119,14 @@ impl FromHandle for HandleOrInvalid {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for HandleOrInvalid {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for std::fs::File {
|
||||
#[inline]
|
||||
@@ -143,6 +151,14 @@ impl IntoFd for std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<std::fs::File> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::fs::File) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for std::fs::File {
|
||||
#[inline]
|
||||
@@ -151,6 +167,14 @@ impl IntoHandle for std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::fs::File> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::fs::File) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for std::fs::File {
|
||||
#[inline]
|
||||
@@ -159,6 +183,14 @@ impl FromFd for std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for std::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for std::fs::File {
|
||||
#[inline]
|
||||
@@ -167,6 +199,14 @@ impl FromHandle for std::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for std::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -191,6 +231,14 @@ impl IntoFd for std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<std::net::TcpStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -199,6 +247,14 @@ impl IntoSocket for std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::net::TcpStream> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: std::net::TcpStream) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -207,6 +263,14 @@ impl FromFd for std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for std::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for std::net::TcpStream {
|
||||
#[inline]
|
||||
@@ -215,6 +279,14 @@ impl FromSocket for std::net::TcpStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for std::net::TcpStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -239,6 +311,14 @@ impl IntoFd for std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<std::net::TcpListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -247,6 +327,14 @@ impl IntoSocket for std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::net::TcpListener> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: std::net::TcpListener) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -255,6 +343,14 @@ impl FromFd for std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for std::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for std::net::TcpListener {
|
||||
#[inline]
|
||||
@@ -263,6 +359,14 @@ impl FromSocket for std::net::TcpListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for std::net::TcpListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -287,6 +391,14 @@ impl IntoFd for std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<std::net::UdpSocket> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoSocket for std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -295,6 +407,14 @@ impl IntoSocket for std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::net::UdpSocket> for OwnedSocket {
|
||||
#[inline]
|
||||
fn from(owned: std::net::UdpSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl FromFd for std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -303,6 +423,14 @@ impl FromFd for std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for std::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromSocket for std::net::UdpSocket {
|
||||
#[inline]
|
||||
@@ -311,6 +439,14 @@ impl FromSocket for std::net::UdpSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedSocket> for std::net::UdpSocket {
|
||||
#[inline]
|
||||
fn from(owned: OwnedSocket) -> Self {
|
||||
unsafe { Self::from_raw_socket(owned.into_raw_socket()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for std::io::Stdin {
|
||||
#[inline]
|
||||
@@ -431,6 +567,14 @@ impl IntoFd for std::process::ChildStdin {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::process::ChildStdin> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStdin) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for std::process::ChildStdin {
|
||||
#[inline]
|
||||
@@ -439,6 +583,14 @@ impl IntoHandle for std::process::ChildStdin {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::process::ChildStdin> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStdin) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl AsFd for std::process::ChildStdout {
|
||||
#[inline]
|
||||
@@ -463,6 +615,14 @@ impl IntoFd for std::process::ChildStdout {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::process::ChildStdout> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStdout) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for std::process::ChildStdout {
|
||||
#[inline]
|
||||
@@ -471,6 +631,14 @@ impl IntoHandle for std::process::ChildStdout {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::process::ChildStdout> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStdout) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl AsFd for std::process::ChildStderr {
|
||||
#[inline]
|
||||
@@ -495,6 +663,14 @@ impl IntoFd for std::process::ChildStderr {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::process::ChildStderr> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStderr) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl IntoHandle for std::process::ChildStderr {
|
||||
#[inline]
|
||||
@@ -503,6 +679,14 @@ impl IntoHandle for std::process::ChildStderr {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::process::ChildStderr> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::process::ChildStderr) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for std::process::Stdio {
|
||||
#[inline]
|
||||
@@ -511,6 +695,14 @@ impl FromFd for std::process::Stdio {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for std::process::Stdio {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for std::process::Stdio {
|
||||
#[inline]
|
||||
@@ -519,6 +711,14 @@ impl FromHandle for std::process::Stdio {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for std::process::Stdio {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl AsHandle for std::process::Child {
|
||||
#[inline]
|
||||
@@ -535,6 +735,14 @@ impl IntoHandle for std::process::Child {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<std::process::Child> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::process::Child) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl AsFd for std::os::unix::net::UnixStream {
|
||||
#[inline]
|
||||
@@ -551,6 +759,14 @@ impl IntoFd for std::os::unix::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::os::unix::net::UnixStream> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::os::unix::net::UnixStream) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for std::os::unix::net::UnixStream {
|
||||
#[inline]
|
||||
@@ -559,6 +775,14 @@ impl FromFd for std::os::unix::net::UnixStream {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for std::os::unix::net::UnixStream {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl AsFd for std::os::unix::net::UnixListener {
|
||||
#[inline]
|
||||
@@ -575,6 +799,14 @@ impl IntoFd for std::os::unix::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::os::unix::net::UnixListener> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::os::unix::net::UnixListener) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for std::os::unix::net::UnixListener {
|
||||
#[inline]
|
||||
@@ -583,6 +815,14 @@ impl FromFd for std::os::unix::net::UnixListener {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for std::os::unix::net::UnixListener {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl AsFd for std::os::unix::net::UnixDatagram {
|
||||
#[inline]
|
||||
@@ -599,6 +839,14 @@ impl IntoFd for std::os::unix::net::UnixDatagram {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<std::os::unix::net::UnixDatagram> for OwnedFd {
|
||||
#[inline]
|
||||
fn from(owned: std::os::unix::net::UnixDatagram) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl FromFd for std::os::unix::net::UnixDatagram {
|
||||
#[inline]
|
||||
@@ -607,6 +855,14 @@ impl FromFd for std::os::unix::net::UnixDatagram {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
impl From<OwnedFd> for std::os::unix::net::UnixDatagram {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl<T> AsHandle for std::thread::JoinHandle<T> {
|
||||
#[inline]
|
||||
@@ -622,3 +878,11 @@ impl<T> IntoHandle for std::thread::JoinHandle<T> {
|
||||
unsafe { OwnedHandle::from_raw_handle(self.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl<T> From<std::thread::JoinHandle<T>> for OwnedHandle {
|
||||
#[inline]
|
||||
fn from(owned: std::thread::JoinHandle<T>) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,14 @@ impl FromFd for tokio::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl From<OwnedFd> for tokio::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedFd) -> Self {
|
||||
unsafe { Self::from_raw_fd(owned.into_raw_fd()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl FromHandle for tokio::fs::File {
|
||||
#[inline]
|
||||
@@ -45,6 +53,14 @@ impl FromHandle for tokio::fs::File {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
impl From<OwnedHandle> for tokio::fs::File {
|
||||
#[inline]
|
||||
fn from(owned: OwnedHandle) -> Self {
|
||||
unsafe { Self::from_raw_handle(owned.into_raw_handle()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "wasi"))]
|
||||
impl AsFd for tokio::net::TcpStream {
|
||||
#[inline]
|
||||
|
||||
Reference in New Issue
Block a user