summaryrefslogtreecommitdiffstats
path: root/vendor/io-lifetimes/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /vendor/io-lifetimes/src
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/io-lifetimes/src')
-rw-r--r--vendor/io-lifetimes/src/example_ffi.rs4
-rw-r--r--vendor/io-lifetimes/src/impls_async_std.rs16
-rw-r--r--vendor/io-lifetimes/src/impls_mio.rs24
-rw-r--r--vendor/io-lifetimes/src/impls_os_pipe.rs5
-rw-r--r--vendor/io-lifetimes/src/impls_socket2.rs3
-rw-r--r--vendor/io-lifetimes/src/impls_std.rs2
-rw-r--r--vendor/io-lifetimes/src/impls_std_views.rs31
-rw-r--r--vendor/io-lifetimes/src/lib.rs56
-rw-r--r--vendor/io-lifetimes/src/portability.rs93
-rw-r--r--vendor/io-lifetimes/src/traits.rs72
-rw-r--r--vendor/io-lifetimes/src/types.rs34
-rw-r--r--vendor/io-lifetimes/src/views.rs73
12 files changed, 200 insertions, 213 deletions
diff --git a/vendor/io-lifetimes/src/example_ffi.rs b/vendor/io-lifetimes/src/example_ffi.rs
index 8f7c238ba..0b31b9ec2 100644
--- a/vendor/io-lifetimes/src/example_ffi.rs
+++ b/vendor/io-lifetimes/src/example_ffi.rs
@@ -1,6 +1,6 @@
//! This is just a sample of what FFI using this crate can look like.
-#![cfg_attr(not(rustc_attrs), allow(unused_imports))]
+#![cfg_attr(not(io_safety_is_in_std), allow(unused_imports))]
#![allow(missing_docs)]
#[cfg(any(unix, target_os = "wasi"))]
@@ -23,7 +23,7 @@ use {
};
// Declare a few FFI functions ourselves, to show off the FFI ergonomics.
-#[cfg(all(rustc_attrs, any(unix, target_os = "wasi")))]
+#[cfg(all(io_safety_is_in_std, any(unix, target_os = "wasi")))]
extern "C" {
pub fn open(pathname: *const c_char, flags: c_int, ...) -> Option<OwnedFd>;
}
diff --git a/vendor/io-lifetimes/src/impls_async_std.rs b/vendor/io-lifetimes/src/impls_async_std.rs
index 534700486..7223e9955 100644
--- a/vendor/io-lifetimes/src/impls_async_std.rs
+++ b/vendor/io-lifetimes/src/impls_async_std.rs
@@ -2,7 +2,6 @@
//! future, we'll prefer to have crates provide their own impls; this is
//! just a temporary measure.
-use crate::views::{FilelikeViewType, SocketlikeViewType};
#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
#[cfg(windows)]
@@ -101,8 +100,6 @@ impl From<OwnedHandle> for async_std::fs::File {
}
}
-unsafe impl SocketlikeViewType for async_std::net::TcpStream {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for async_std::net::TcpStream {
#[inline]
@@ -183,8 +180,6 @@ impl From<OwnedSocket> for async_std::net::TcpStream {
}
}
-unsafe impl SocketlikeViewType for async_std::net::TcpListener {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for async_std::net::TcpListener {
#[inline]
@@ -265,8 +260,6 @@ impl From<OwnedSocket> for async_std::net::TcpListener {
}
}
-unsafe impl SocketlikeViewType for async_std::net::UdpSocket {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for async_std::net::UdpSocket {
#[inline]
@@ -396,9 +389,6 @@ impl AsHandle for async_std::io::Stderr {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixStream {}
-
-#[cfg(unix)]
impl AsFd for async_std::os::unix::net::UnixStream {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -439,9 +429,6 @@ impl From<OwnedFd> for async_std::os::unix::net::UnixStream {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixListener {}
-
-#[cfg(unix)]
impl AsFd for async_std::os::unix::net::UnixListener {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -482,9 +469,6 @@ impl From<OwnedFd> for async_std::os::unix::net::UnixListener {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixDatagram {}
-
-#[cfg(unix)]
impl AsFd for async_std::os::unix::net::UnixDatagram {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
diff --git a/vendor/io-lifetimes/src/impls_mio.rs b/vendor/io-lifetimes/src/impls_mio.rs
index 246f3b93f..486274b09 100644
--- a/vendor/io-lifetimes/src/impls_mio.rs
+++ b/vendor/io-lifetimes/src/impls_mio.rs
@@ -2,9 +2,6 @@
//! future, we'll prefer to have crates provide their own impls; this is
//! just a temporary measure.
-#[cfg(unix)]
-use crate::views::FilelikeViewType;
-use crate::views::SocketlikeViewType;
#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
#[cfg(windows)]
@@ -16,8 +13,6 @@ use std::os::wasi::io::{AsRawFd, FromRawFd, IntoRawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket};
-unsafe impl SocketlikeViewType for mio::net::TcpStream {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for mio::net::TcpStream {
#[inline]
@@ -98,8 +93,6 @@ impl From<OwnedSocket> for mio::net::TcpStream {
}
}
-unsafe impl SocketlikeViewType for mio::net::TcpListener {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for mio::net::TcpListener {
#[inline]
@@ -180,8 +173,6 @@ impl From<OwnedSocket> for mio::net::TcpListener {
}
}
-unsafe impl SocketlikeViewType for mio::net::UdpSocket {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for mio::net::UdpSocket {
#[inline]
@@ -263,9 +254,6 @@ impl From<OwnedSocket> for mio::net::UdpSocket {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for mio::net::UnixDatagram {}
-
-#[cfg(unix)]
impl AsFd for mio::net::UnixDatagram {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -306,9 +294,6 @@ impl From<OwnedFd> for mio::net::UnixDatagram {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for mio::net::UnixListener {}
-
-#[cfg(unix)]
impl AsFd for mio::net::UnixListener {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -349,9 +334,6 @@ impl From<OwnedFd> for mio::net::UnixListener {
}
#[cfg(unix)]
-unsafe impl SocketlikeViewType for mio::net::UnixStream {}
-
-#[cfg(unix)]
impl AsFd for mio::net::UnixStream {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -392,9 +374,6 @@ impl From<OwnedFd> for mio::net::UnixStream {
}
#[cfg(unix)]
-unsafe impl FilelikeViewType for mio::unix::pipe::Receiver {}
-
-#[cfg(unix)]
impl AsFd for mio::unix::pipe::Receiver {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -435,9 +414,6 @@ impl From<OwnedFd> for mio::unix::pipe::Receiver {
}
#[cfg(unix)]
-unsafe impl FilelikeViewType for mio::unix::pipe::Sender {}
-
-#[cfg(unix)]
impl AsFd for mio::unix::pipe::Sender {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
diff --git a/vendor/io-lifetimes/src/impls_os_pipe.rs b/vendor/io-lifetimes/src/impls_os_pipe.rs
index e0544873e..4c1d1bf67 100644
--- a/vendor/io-lifetimes/src/impls_os_pipe.rs
+++ b/vendor/io-lifetimes/src/impls_os_pipe.rs
@@ -2,7 +2,6 @@
//! future, we'll prefer to have crates provide their own impls; this is
//! just a temporary measure.
-use crate::views::FilelikeViewType;
#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
#[cfg(windows)]
@@ -14,8 +13,6 @@ use std::os::wasi::io::{AsRawFd, FromRawFd, IntoRawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle};
-unsafe impl FilelikeViewType for os_pipe::PipeReader {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for os_pipe::PipeReader {
#[inline]
@@ -96,8 +93,6 @@ impl From<OwnedHandle> for os_pipe::PipeReader {
}
}
-unsafe impl FilelikeViewType for os_pipe::PipeWriter {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for os_pipe::PipeWriter {
#[inline]
diff --git a/vendor/io-lifetimes/src/impls_socket2.rs b/vendor/io-lifetimes/src/impls_socket2.rs
index fbfeb67d7..3dc4f9eea 100644
--- a/vendor/io-lifetimes/src/impls_socket2.rs
+++ b/vendor/io-lifetimes/src/impls_socket2.rs
@@ -2,7 +2,6 @@
//! future, we'll prefer to have crates provide their own impls; this is
//! just a temporary measure.
-use crate::views::SocketlikeViewType;
#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
#[cfg(windows)]
@@ -14,8 +13,6 @@ use std::os::wasi::io::{AsRawFd, FromRawFd, IntoRawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket};
-unsafe impl SocketlikeViewType for socket2::Socket {}
-
#[cfg(any(unix, target_os = "wasi"))]
impl AsFd for socket2::Socket {
#[inline]
diff --git a/vendor/io-lifetimes/src/impls_std.rs b/vendor/io-lifetimes/src/impls_std.rs
index 27275fa68..145bb1982 100644
--- a/vendor/io-lifetimes/src/impls_std.rs
+++ b/vendor/io-lifetimes/src/impls_std.rs
@@ -1,3 +1,5 @@
+#![allow(deprecated)] // Don't warn on `IntoFd` and `FromFd` impls.
+
#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, FromFd, IntoFd};
#[cfg(windows)]
diff --git a/vendor/io-lifetimes/src/impls_std_views.rs b/vendor/io-lifetimes/src/impls_std_views.rs
deleted file mode 100644
index ffa013ffa..000000000
--- a/vendor/io-lifetimes/src/impls_std_views.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-use crate::views::{FilelikeViewType, SocketlikeViewType};
-#[cfg(any(unix, target_os = "wasi"))]
-use crate::OwnedFd;
-#[cfg(windows)]
-use crate::{OwnedHandle, OwnedSocket};
-
-#[cfg(any(unix, target_os = "wasi"))]
-unsafe impl FilelikeViewType for OwnedFd {}
-
-#[cfg(windows)]
-unsafe impl FilelikeViewType for OwnedHandle {}
-
-#[cfg(windows)]
-unsafe impl SocketlikeViewType for OwnedSocket {}
-
-unsafe impl FilelikeViewType for std::fs::File {}
-
-unsafe impl SocketlikeViewType for std::net::TcpStream {}
-
-unsafe impl SocketlikeViewType for std::net::TcpListener {}
-
-unsafe impl SocketlikeViewType for std::net::UdpSocket {}
-
-#[cfg(unix)]
-unsafe impl SocketlikeViewType for std::os::unix::net::UnixStream {}
-
-#[cfg(unix)]
-unsafe impl SocketlikeViewType for std::os::unix::net::UnixListener {}
-
-#[cfg(unix)]
-unsafe impl SocketlikeViewType for std::os::unix::net::UnixDatagram {}
diff --git a/vendor/io-lifetimes/src/lib.rs b/vendor/io-lifetimes/src/lib.rs
index 5e2a9d19f..da5e740cf 100644
--- a/vendor/io-lifetimes/src/lib.rs
+++ b/vendor/io-lifetimes/src/lib.rs
@@ -28,47 +28,47 @@
//! [from+into conversions]: FromFilelike::from_into_filelike
#![deny(missing_docs)]
-#![cfg_attr(rustc_attrs, feature(rustc_attrs))]
-#![cfg_attr(all(io_lifetimes_use_std, target_os = "wasi"), feature(wasi_ext))]
-#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
+// Work around https://github.com/rust-lang/rust/issues/103306.
+#![cfg_attr(all(wasi_ext, target_os = "wasi"), feature(wasi_ext))]
mod portability;
mod traits;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
mod types;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
mod impls_std;
-mod impls_std_views;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
pub use traits::AsFd;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
pub use traits::{AsHandle, AsSocket};
#[cfg(any(unix, target_os = "wasi"))]
+#[allow(deprecated)]
pub use traits::{FromFd, IntoFd};
#[cfg(windows)]
+#[allow(deprecated)]
pub use traits::{FromHandle, FromSocket, IntoHandle, IntoSocket};
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
pub use types::{BorrowedFd, OwnedFd};
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
pub use types::{
BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError, NullHandleError,
OwnedHandle, OwnedSocket,
};
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(unix)]
pub use std::os::unix::io::{AsFd, BorrowedFd, OwnedFd};
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(target_os = "wasi")]
pub use std::os::wasi::io::{AsFd, BorrowedFd, OwnedFd};
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(windows)]
pub use std::os::windows::io::{
AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, HandleOrInvalid, InvalidHandleError,
@@ -86,16 +86,18 @@ pub use std::os::windows::io::{
//
// So we define `FromFd`/`IntoFd` traits, and implement them in terms of
// `From`/`Into`,
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(any(unix, target_os = "wasi"))]
+#[allow(deprecated)]
impl<T: From<OwnedFd>> FromFd for T {
#[inline]
fn from_fd(owned_fd: OwnedFd) -> Self {
owned_fd.into()
}
}
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(any(unix, target_os = "wasi"))]
+#[allow(deprecated)]
impl<T> IntoFd for T
where
OwnedFd: From<T>,
@@ -106,16 +108,18 @@ where
}
}
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(windows)]
+#[allow(deprecated)]
impl<T: From<OwnedHandle>> FromHandle for T {
#[inline]
fn from_handle(owned_handle: OwnedHandle) -> Self {
owned_handle.into()
}
}
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(windows)]
+#[allow(deprecated)]
impl<T> IntoHandle for T
where
OwnedHandle: From<T>,
@@ -126,16 +130,18 @@ where
}
}
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(windows)]
+#[allow(deprecated)]
impl<T: From<OwnedSocket>> FromSocket for T {
#[inline]
fn from_socket(owned_socket: OwnedSocket) -> Self {
owned_socket.into()
}
}
-#[cfg(io_lifetimes_use_std)]
+#[cfg(io_safety_is_in_std)]
#[cfg(windows)]
+#[allow(deprecated)]
impl<T> IntoSocket for T
where
OwnedSocket: From<T>,
@@ -158,22 +164,22 @@ pub mod views;
// Ideally, we'd want crates to implement our traits themselves. But for now,
// while we're prototyping, we provide a few impls on foreign types.
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "async-std")]
mod impls_async_std;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "fs-err")]
mod impls_fs_err;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "mio")]
mod impls_mio;
#[cfg(not(target_os = "wasi"))]
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "os_pipe")]
mod impls_os_pipe;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "socket2")]
mod impls_socket2;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(feature = "tokio")]
mod impls_tokio;
diff --git a/vendor/io-lifetimes/src/portability.rs b/vendor/io-lifetimes/src/portability.rs
index ee9057501..eb630ce9f 100644
--- a/vendor/io-lifetimes/src/portability.rs
+++ b/vendor/io-lifetimes/src/portability.rs
@@ -6,12 +6,9 @@
use crate::views::{FilelikeView, FilelikeViewType, SocketlikeView, SocketlikeViewType};
#[cfg(any(unix, target_os = "wasi"))]
-use crate::{AsFd, BorrowedFd, FromFd, IntoFd, OwnedFd};
+use crate::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
-use crate::{
- AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, FromHandle, FromSocket, IntoHandle,
- IntoSocket, OwnedHandle, OwnedSocket,
-};
+use crate::{AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, OwnedHandle, OwnedSocket};
/// A reference to a filelike object.
///
@@ -104,6 +101,8 @@ pub trait AsFilelike: AsFd {
/// ```
///
/// [`File`]: std::fs::File
+ /// [`Read`]: std::io::Read
+ /// [`Write`]: std::io::Write
fn as_filelike_view<Target: FilelikeViewType>(&self) -> FilelikeView<'_, Target>;
}
@@ -155,6 +154,8 @@ pub trait AsFilelike: AsHandle {
/// ```
///
/// [`File`]: std::fs::File
+ /// [`Read`]: std::io::Read
+ /// [`Write`]: std::io::Write
fn as_filelike_view<Target: FilelikeViewType>(&self) -> FilelikeView<'_, Target>;
}
@@ -195,6 +196,8 @@ pub trait AsSocketlike: AsFd {
/// ```
///
/// [`TcpStream`]: std::net::TcpStream
+ /// [`Read`]: std::io::Read
+ /// [`Write`]: std::io::Write
fn as_socketlike_view<Target: SocketlikeViewType>(&self) -> SocketlikeView<'_, Target>;
}
@@ -254,10 +257,10 @@ impl<T: AsSocket> AsSocketlike for T {
/// A portable trait to express the ability to consume an object and acquire
/// ownership of its filelike object.
///
-/// This is a portability abstraction over Unix-like [`IntoFd`] and Windows'
-/// `IntoHandle`.
+/// This is a portability abstraction over Unix-like [`Into<OwnedFd>`] and Windows'
+/// `Into<OwnedHandle>`.
#[cfg(any(unix, target_os = "wasi"))]
-pub trait IntoFilelike: IntoFd {
+pub trait IntoFilelike: Into<OwnedFd> {
/// Consumes this object, returning the underlying filelike object.
///
/// # Example
@@ -275,58 +278,58 @@ pub trait IntoFilelike: IntoFd {
}
#[cfg(any(unix, target_os = "wasi"))]
-impl<T: IntoFd> IntoFilelike for T {
+impl<T: Into<OwnedFd>> IntoFilelike for T {
#[inline]
fn into_filelike(self) -> OwnedFilelike {
- self.into_fd()
+ self.into()
}
}
/// A portable trait to express the ability to consume an object and acquire
/// ownership of its filelike object.
///
-/// This is a portability abstraction over Unix-like `IntoFd` and Windows'
-/// [`IntoHandle`].
+/// This is a portability abstraction over Unix-like `Into<OwnedFd>` and Windows'
+/// [`Into<OwnedHandle>`].
#[cfg(windows)]
-pub trait IntoFilelike: IntoHandle {
+pub trait IntoFilelike: Into<OwnedHandle> {
/// Consumes this object, returning the underlying filelike object.
fn into_filelike(self) -> OwnedFilelike;
}
#[cfg(windows)]
-impl<T: IntoHandle> IntoFilelike for T {
+impl<T: Into<OwnedHandle>> IntoFilelike for T {
#[inline]
fn into_filelike(self) -> OwnedFilelike {
- self.into_handle()
+ self.into()
}
}
/// A portable trait to express the ability to consume an object and acquire
/// ownership of its socketlike object.
///
-/// This is a portability abstraction over Unix-like [`IntoFd`] and Windows'
-/// `IntoSocket`.
+/// This is a portability abstraction over Unix-like [`Into<OwnedFd>`] and Windows'
+/// `Into<OwnedSocket>`.
#[cfg(any(unix, target_os = "wasi"))]
-pub trait IntoSocketlike: IntoFd {
+pub trait IntoSocketlike: Into<OwnedFd> {
/// Consumes this object, returning the underlying socketlike object.
fn into_socketlike(self) -> OwnedSocketlike;
}
#[cfg(any(unix, target_os = "wasi"))]
-impl<T: IntoFd> IntoSocketlike for T {
+impl<T: Into<OwnedFd>> IntoSocketlike for T {
#[inline]
fn into_socketlike(self) -> OwnedSocketlike {
- self.into_fd()
+ self.into()
}
}
/// A portable trait to express the ability to consume an object and acquire
/// ownership of its socketlike object.
///
-/// This is a portability abstraction over Unix-like `IntoFd` and Windows'
-/// [`IntoSocket`].
+/// This is a portability abstraction over Unix-like `Into<OwnedFd>` and Windows'
+/// [`Into<OwnedSocket>`].
#[cfg(windows)]
-pub trait IntoSocketlike: IntoSocket {
+pub trait IntoSocketlike: Into<OwnedSocket> {
/// Consumes this object, returning the underlying socketlike object.
///
/// # Example
@@ -344,21 +347,21 @@ pub trait IntoSocketlike: IntoSocket {
}
#[cfg(windows)]
-impl<T: IntoSocket> IntoSocketlike for T {
+impl<T: Into<OwnedSocket>> IntoSocketlike for T {
#[inline]
fn into_socketlike(self) -> OwnedSocketlike {
- self.into_socket()
+ self.into()
}
}
/// A portable trait to express the ability to construct an object from a
/// filelike object.
///
-/// This is a portability abstraction over Unix-like [`FromFd`] and Windows'
-/// `FromHandle`. It also provides the `from_into_filelike` convenience
+/// This is a portability abstraction over Unix-like [`From<OwnedFd>`] and Windows'
+/// `From<OwnedHandle>`. It also provides the `from_into_filelike` convenience
/// function providing simplified from+into conversions.
#[cfg(any(unix, target_os = "wasi"))]
-pub trait FromFilelike: FromFd {
+pub trait FromFilelike: From<OwnedFd> {
/// Constructs a new instance of `Self` from the given filelike object.
///
/// # Example
@@ -393,10 +396,10 @@ pub trait FromFilelike: FromFd {
}
#[cfg(any(unix, target_os = "wasi"))]
-impl<T: FromFd> FromFilelike for T {
+impl<T: From<OwnedFd>> FromFilelike for T {
#[inline]
fn from_filelike(owned: OwnedFilelike) -> Self {
- Self::from_fd(owned)
+ Self::from(owned)
}
#[inline]
@@ -408,11 +411,11 @@ impl<T: FromFd> FromFilelike for T {
/// A portable trait to express the ability to construct an object from a
/// filelike object.
///
-/// This is a portability abstraction over Unix-like `FromFd` and Windows'
-/// [`FromHandle`]. It also provides the `from_into_filelike` convenience
+/// This is a portability abstraction over Unix-like `From<OwnedFd>` and Windows'
+/// [`From<OwnedHandle>`]. It also provides the `from_into_filelike` convenience
/// function providing simplified from+into conversions.
#[cfg(windows)]
-pub trait FromFilelike: FromHandle {
+pub trait FromFilelike: From<OwnedHandle> {
/// Constructs a new instance of `Self` from the given filelike object.
///
/// # Example
@@ -447,10 +450,10 @@ pub trait FromFilelike: FromHandle {
}
#[cfg(windows)]
-impl<T: FromHandle> FromFilelike for T {
+impl<T: From<OwnedHandle>> FromFilelike for T {
#[inline]
fn from_filelike(owned: OwnedFilelike) -> Self {
- Self::from_handle(owned)
+ Self::from(owned)
}
#[inline]
@@ -462,11 +465,11 @@ impl<T: FromHandle> FromFilelike for T {
/// A portable trait to express the ability to construct an object from a
/// socketlike object.
///
-/// This is a portability abstraction over Unix-like [`FromFd`] and Windows'
-/// `FromSocket`. It also provides the `from_into_socketlike` convenience
+/// This is a portability abstraction over Unix-like [`From<OwnedFd>`] and Windows'
+/// `From<OwnedSocketFrom<OwnedSocket> It also provides the `from_into_socketlike` convenience
/// function providing simplified from+into conversions.
#[cfg(any(unix, target_os = "wasi"))]
-pub trait FromSocketlike: FromFd {
+pub trait FromSocketlike: From<OwnedFd> {
/// Constructs a new instance of `Self` from the given socketlike object.
fn from_socketlike(owned: OwnedSocketlike) -> Self;
@@ -476,10 +479,10 @@ pub trait FromSocketlike: FromFd {
}
#[cfg(any(unix, target_os = "wasi"))]
-impl<T: FromFd> FromSocketlike for T {
+impl<T: From<OwnedFd>> FromSocketlike for T {
#[inline]
fn from_socketlike(owned: OwnedSocketlike) -> Self {
- Self::from_fd(owned)
+ Self::from(owned)
}
#[inline]
@@ -491,11 +494,11 @@ impl<T: FromFd> FromSocketlike for T {
/// A portable trait to express the ability to construct an object from a
/// socketlike object.
///
-/// This is a portability abstraction over Unix-like `FromFd` and Windows'
-/// [`FromSocket`]. It also provides the `from_into_socketlike` convenience
+/// This is a portability abstraction over Unix-like `From<OwnedFd>` and Windows'
+/// [`From<OwnedSocket>`]. It also provides the `from_into_socketlike` convenience
/// function providing simplified from+into conversions.
#[cfg(windows)]
-pub trait FromSocketlike: FromSocket {
+pub trait FromSocketlike: From<OwnedSocket> {
/// Constructs a new instance of `Self` from the given socketlike object.
fn from_socketlike(owned: OwnedSocketlike) -> Self;
@@ -505,10 +508,10 @@ pub trait FromSocketlike: FromSocket {
}
#[cfg(windows)]
-impl<T: FromSocket> FromSocketlike for T {
+impl<T: From<OwnedSocket>> FromSocketlike for T {
#[inline]
fn from_socketlike(owned: OwnedSocketlike) -> Self {
- Self::from_socket(owned)
+ Self::from(owned)
}
#[inline]
diff --git a/vendor/io-lifetimes/src/traits.rs b/vendor/io-lifetimes/src/traits.rs
index 788045208..7fb9a5bdb 100644
--- a/vendor/io-lifetimes/src/traits.rs
+++ b/vendor/io-lifetimes/src/traits.rs
@@ -1,9 +1,9 @@
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
use crate::BorrowedFd;
#[cfg(any(unix, target_os = "wasi"))]
use crate::OwnedFd;
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
use crate::{BorrowedHandle, BorrowedSocket};
#[cfg(windows)]
@@ -14,7 +14,7 @@ use crate::{OwnedHandle, OwnedSocket};
/// This is only available on unix platforms and must be imported in order to
/// call the method. Windows platforms have a corresponding `AsHandle` and
/// `AsSocket` set of traits.
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
pub trait AsFd {
/// Borrows the file descriptor.
@@ -22,7 +22,6 @@ pub trait AsFd {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{AsFd, BorrowedFd};
@@ -35,7 +34,7 @@ pub trait AsFd {
}
/// A trait to borrow the handle from an underlying object.
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
pub trait AsHandle {
/// Borrows the handle.
@@ -43,7 +42,6 @@ pub trait AsHandle {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{AsHandle, BorrowedHandle};
@@ -56,7 +54,7 @@ pub trait AsHandle {
}
/// A trait to borrow the socket from an underlying object.
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
pub trait AsSocket {
/// Borrows the socket.
@@ -66,13 +64,16 @@ pub trait AsSocket {
/// A trait to express the ability to consume an object and acquire ownership
/// of its file descriptor.
#[cfg(any(unix, target_os = "wasi"))]
+#[deprecated(
+ since = "1.0.0",
+ note = "`IntoFd` is replaced by `From<...> for OwnedFd` or `Into<OwnedFd>`"
+)]
pub trait IntoFd {
/// Consumes this object, returning the underlying file descriptor.
///
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{IntoFd, OwnedFd};
@@ -87,13 +88,16 @@ pub trait IntoFd {
/// A trait to express the ability to consume an object and acquire ownership
/// of its handle.
#[cfg(windows)]
+#[deprecated(
+ since = "1.0.0",
+ note = "`IntoHandle` is replaced by `From<...> for OwnedHandle` or `Into<OwnedHandle>`"
+)]
pub trait IntoHandle {
/// Consumes this object, returning the underlying handle.
///
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{IntoHandle, OwnedHandle};
@@ -108,6 +112,10 @@ pub trait IntoHandle {
/// A trait to express the ability to consume an object and acquire ownership
/// of its socket.
#[cfg(windows)]
+#[deprecated(
+ since = "1.0.0",
+ note = "`IntoSocket` is replaced by `From<...> for OwnedSocket` or `Into<OwnedSocket>`"
+)]
pub trait IntoSocket {
/// Consumes this object, returning the underlying socket.
fn into_socket(self) -> OwnedSocket;
@@ -122,7 +130,6 @@ pub trait FromFd {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{FromFd, IntoFd, OwnedFd};
@@ -132,6 +139,10 @@ pub trait FromFd {
/// let f = File::from_fd(owned_fd);
/// # Ok::<(), io::Error>(())
/// ```
+ #[deprecated(
+ since = "1.0.0",
+ note = "`FromFd::from_fd` is replaced by `From<OwnedFd>::from`"
+ )]
fn from_fd(owned: OwnedFd) -> Self;
/// Constructs a new instance of `Self` from the given file descriptor
@@ -140,7 +151,6 @@ pub trait FromFd {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{FromFd, IntoFd};
@@ -150,11 +160,11 @@ pub trait FromFd {
/// # Ok::<(), io::Error>(())
/// ```
#[inline]
- fn from_into_fd<Owned: IntoFd>(into_owned: Owned) -> Self
+ fn from_into_fd<Owned: Into<OwnedFd>>(into_owned: Owned) -> Self
where
- Self: Sized,
+ Self: Sized + From<OwnedFd>,
{
- Self::from_fd(into_owned.into_fd())
+ Self::from(into_owned.into())
}
}
@@ -166,7 +176,6 @@ pub trait FromHandle {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{FromHandle, IntoHandle, OwnedHandle};
@@ -176,6 +185,10 @@ pub trait FromHandle {
/// let f = File::from_handle(owned_handle);
/// # Ok::<(), io::Error>(())
/// ```
+ #[deprecated(
+ since = "1.0.0",
+ note = "`FromHandle::from_handle` is replaced by `From<OwnedHandle>::from`"
+ )]
fn from_handle(owned: OwnedHandle) -> Self;
/// Constructs a new instance of `Self` from the given handle converted
@@ -184,7 +197,6 @@ pub trait FromHandle {
/// # Example
///
/// ```rust,no_run
- /// # #![cfg_attr(io_lifetimes_use_std, feature(io_safety))]
/// use std::fs::File;
/// # use std::io;
/// use io_lifetimes::{FromHandle, IntoHandle};
@@ -194,11 +206,11 @@ pub trait FromHandle {
/// # Ok::<(), io::Error>(())
/// ```
#[inline]
- fn from_into_handle<Owned: IntoHandle>(into_owned: Owned) -> Self
+ fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
where
- Self: Sized,
+ Self: Sized + From<OwnedHandle>,
{
- Self::from_handle(into_owned.into_handle())
+ Self::from(into_owned.into())
}
}
@@ -206,20 +218,24 @@ pub trait FromHandle {
#[cfg(windows)]
pub trait FromSocket {
/// Constructs a new instance of `Self` from the given socket.
+ #[deprecated(
+ since = "1.0.0",
+ note = "`FromSocket::from_socket` is replaced by `From<OwnedSocket>::from`"
+ )]
fn from_socket(owned: OwnedSocket) -> Self;
/// Constructs a new instance of `Self` from the given socket converted
/// from `into_owned`.
#[inline]
- fn from_into_socket<Owned: IntoSocket>(into_owned: Owned) -> Self
+ fn from_into_socket<Owned: Into<OwnedSocket>>(into_owned: Owned) -> Self
where
- Self: Sized,
+ Self: Sized + From<OwnedSocket>,
{
- Self::from_socket(into_owned.into_socket())
+ Self::from(into_owned.into())
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
impl<T: AsFd> AsFd for &T {
#[inline]
@@ -228,7 +244,7 @@ impl<T: AsFd> AsFd for &T {
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(any(unix, target_os = "wasi"))]
impl<T: AsFd> AsFd for &mut T {
#[inline]
@@ -237,7 +253,7 @@ impl<T: AsFd> AsFd for &mut T {
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
impl<T: AsHandle> AsHandle for &T {
#[inline]
@@ -246,7 +262,7 @@ impl<T: AsHandle> AsHandle for &T {
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
impl<T: AsHandle> AsHandle for &mut T {
#[inline]
@@ -255,7 +271,7 @@ impl<T: AsHandle> AsHandle for &mut T {
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
impl<T: AsSocket> AsSocket for &T {
#[inline]
@@ -264,7 +280,7 @@ impl<T: AsSocket> AsSocket for &T {
}
}
-#[cfg(not(io_lifetimes_use_std))]
+#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
impl<T: AsSocket> AsSocket for &mut T {
#[inline]
diff --git a/vendor/io-lifetimes/src/types.rs b/vendor/io-lifetimes/src/types.rs
index 695ae513c..7f7809fb0 100644
--- a/vendor/io-lifetimes/src/types.rs
+++ b/vendor/io-lifetimes/src/types.rs
@@ -50,12 +50,6 @@ const INVALID_SOCKET: usize = !0 as _;
#[cfg(any(unix, target_os = "wasi"))]
#[derive(Copy, Clone)]
#[repr(transparent)]
-#[cfg_attr(rustc_attrs, rustc_nonnull_optimization_guaranteed)]
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0))]
-// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a
-// 32-bit c_int. Below is -2, in two's complement, but that only works out
-// because c_int is 32 bits.
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE))]
pub struct BorrowedFd<'fd> {
fd: RawFd,
_phantom: PhantomData<&'fd OwnedFd>,
@@ -105,17 +99,6 @@ pub struct BorrowedHandle<'handle> {
#[cfg(windows)]
#[derive(Copy, Clone)]
#[repr(transparent)]
-#[cfg_attr(rustc_attrs, rustc_nonnull_optimization_guaranteed)]
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0))]
-// This is -2, in two's complement. -1 is `INVALID_SOCKET`.
-#[cfg_attr(
- all(rustc_attrs, target_pointer_width = "32"),
- rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)
-)]
-#[cfg_attr(
- all(rustc_attrs, target_pointer_width = "64"),
- rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE)
-)]
pub struct BorrowedSocket<'socket> {
socket: RawSocket,
_phantom: PhantomData<&'socket OwnedSocket>,
@@ -131,12 +114,6 @@ pub struct BorrowedSocket<'socket> {
/// has the value `-1`.
#[cfg(any(unix, target_os = "wasi"))]
#[repr(transparent)]
-#[cfg_attr(rustc_attrs, rustc_nonnull_optimization_guaranteed)]
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0))]
-// libstd/os/raw/mod.rs assures me that every libstd-supported platform has a
-// 32-bit c_int. Below is -2, in two's complement, but that only works out
-// because c_int is 32 bits.
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE))]
pub struct OwnedFd {
fd: RawFd,
}
@@ -286,17 +263,6 @@ impl BorrowedHandle<'_> {
/// [`INVALID_SOCKET`].
#[cfg(windows)]
#[repr(transparent)]
-#[cfg_attr(rustc_attrs, rustc_nonnull_optimization_guaranteed)]
-#[cfg_attr(rustc_attrs, rustc_layout_scalar_valid_range_start(0))]
-// This is -2, in two's complement. -1 is `INVALID_SOCKET`.
-#[cfg_attr(
- all(rustc_attrs, target_pointer_width = "32"),
- rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FE)
-)]
-#[cfg_attr(
- all(rustc_attrs, target_pointer_width = "64"),
- rustc_layout_scalar_valid_range_end(0xFF_FF_FF_FF_FF_FF_FF_FE)
-)]
pub struct OwnedSocket {
socket: RawSocket,
}
diff --git a/vendor/io-lifetimes/src/views.rs b/vendor/io-lifetimes/src/views.rs
index aec3750a0..b74a8c387 100644
--- a/vendor/io-lifetimes/src/views.rs
+++ b/vendor/io-lifetimes/src/views.rs
@@ -9,10 +9,14 @@ use crate::raw::{
AsRawFilelike, AsRawSocketlike, FromRawFilelike, FromRawSocketlike, IntoRawFilelike,
IntoRawSocketlike, RawFilelike, RawSocketlike,
};
+#[cfg(any(unix, target_os = "wasi"))]
+use crate::OwnedFd;
use crate::{
AsFilelike, AsSocketlike, FromFilelike, FromSocketlike, IntoFilelike, IntoSocketlike,
OwnedFilelike, OwnedSocketlike,
};
+#[cfg(windows)]
+use crate::{OwnedHandle, OwnedSocket};
use std::fmt;
use std::marker::PhantomData;
use std::mem::ManuallyDrop;
@@ -202,3 +206,72 @@ impl<Target: SocketlikeViewType> fmt::Debug for SocketlikeView<'_, Target> {
.finish()
}
}
+
+#[cfg(any(unix, target_os = "wasi"))]
+unsafe impl FilelikeViewType for OwnedFd {}
+#[cfg(windows)]
+unsafe impl FilelikeViewType for OwnedHandle {}
+#[cfg(windows)]
+unsafe impl SocketlikeViewType for OwnedSocket {}
+unsafe impl FilelikeViewType for std::fs::File {}
+unsafe impl SocketlikeViewType for std::net::TcpStream {}
+unsafe impl SocketlikeViewType for std::net::TcpListener {}
+unsafe impl SocketlikeViewType for std::net::UdpSocket {}
+#[cfg(unix)]
+unsafe impl SocketlikeViewType for std::os::unix::net::UnixStream {}
+#[cfg(unix)]
+unsafe impl SocketlikeViewType for std::os::unix::net::UnixListener {}
+
+#[cfg(unix)]
+unsafe impl SocketlikeViewType for std::os::unix::net::UnixDatagram {}
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "os_pipe")]
+unsafe impl FilelikeViewType for os_pipe::PipeWriter {}
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "os_pipe")]
+unsafe impl FilelikeViewType for os_pipe::PipeReader {}
+
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "socket2")]
+unsafe impl SocketlikeViewType for socket2::Socket {}
+
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::net::TcpStream {}
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::net::TcpListener {}
+#[cfg(not(target_os = "wasi"))]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::net::UdpSocket {}
+#[cfg(unix)]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixStream {}
+#[cfg(unix)]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixListener {}
+#[cfg(unix)]
+#[cfg(feature = "async_std")]
+unsafe impl SocketlikeViewType for async_std::os::unix::net::UnixDatagram {}
+
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::TcpStream {}
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::TcpListener {}
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::UdpSocket {}
+#[cfg(unix)]
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::UnixDatagram {}
+#[cfg(unix)]
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::UnixListener {}
+#[cfg(unix)]
+#[cfg(feature = "mio")]
+unsafe impl SocketlikeViewType for mio::net::UnixStream {}
+#[cfg(unix)]
+#[cfg(feature = "mio")]
+unsafe impl FilelikeViewType for mio::unix::pipe::Receiver {}
+#[cfg(unix)]
+#[cfg(feature = "mio")]
+unsafe impl FilelikeViewType for mio::unix::pipe::Sender {}