summaryrefslogtreecommitdiffstats
path: root/vendor/io-lifetimes/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/io-lifetimes/src
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+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.rs9
-rw-r--r--vendor/io-lifetimes/src/impls_std.rs66
-rw-r--r--vendor/io-lifetimes/src/lib.rs17
-rw-r--r--vendor/io-lifetimes/src/portability.rs119
-rw-r--r--vendor/io-lifetimes/src/raw.rs34
-rw-r--r--vendor/io-lifetimes/src/traits.rs14
-rw-r--r--vendor/io-lifetimes/src/types.rs48
-rw-r--r--vendor/io-lifetimes/src/views.rs16
8 files changed, 179 insertions, 144 deletions
diff --git a/vendor/io-lifetimes/src/example_ffi.rs b/vendor/io-lifetimes/src/example_ffi.rs
index 0b31b9ec2..e77560baa 100644
--- a/vendor/io-lifetimes/src/example_ffi.rs
+++ b/vendor/io-lifetimes/src/example_ffi.rs
@@ -3,12 +3,12 @@
#![cfg_attr(not(io_safety_is_in_std), allow(unused_imports))]
#![allow(missing_docs)]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::{BorrowedFd, OwnedFd};
#[cfg(windows)]
use crate::{BorrowedHandle, HandleOrInvalid};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use libc::{c_char, c_int, c_void, size_t, ssize_t};
#[cfg(windows)]
use {
@@ -23,7 +23,10 @@ use {
};
// Declare a few FFI functions ourselves, to show off the FFI ergonomics.
-#[cfg(all(io_safety_is_in_std, any(unix, target_os = "wasi")))]
+#[cfg(all(
+ io_safety_is_in_std,
+ any(unix, target_os = "wasi", target_os = "hermit")
+))]
extern "C" {
pub fn open(pathname: *const c_char, flags: c_int, ...) -> Option<OwnedFd>;
}
diff --git a/vendor/io-lifetimes/src/impls_std.rs b/vendor/io-lifetimes/src/impls_std.rs
index 145bb1982..8adbcfab7 100644
--- a/vendor/io-lifetimes/src/impls_std.rs
+++ b/vendor/io-lifetimes/src/impls_std.rs
@@ -1,13 +1,15 @@
#![allow(deprecated)] // Don't warn on `IntoFd` and `FromFd` impls.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::{AsFd, FromFd, IntoFd};
#[cfg(windows)]
use crate::{AsHandle, AsSocket, FromHandle, FromSocket, IntoHandle, IntoSocket};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::{BorrowedFd, OwnedFd};
#[cfg(windows)]
use crate::{BorrowedHandle, BorrowedSocket, HandleOrInvalid, OwnedHandle, OwnedSocket};
+#[cfg(target_os = "hermit")]
+use std::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
#[cfg(target_os = "wasi")]
@@ -17,7 +19,7 @@ use std::os::windows::io::{
AsRawHandle, AsRawSocket, FromRawHandle, FromRawSocket, IntoRawHandle, IntoRawSocket,
};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for BorrowedFd<'_> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -41,7 +43,7 @@ impl AsSocket for BorrowedSocket<'_> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for OwnedFd {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -65,7 +67,7 @@ impl AsSocket for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoFd for OwnedFd {
#[inline]
fn into_fd(self) -> OwnedFd {
@@ -89,7 +91,7 @@ impl IntoSocket for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromFd for OwnedFd {
#[inline]
fn from_fd(owned: OwnedFd) -> Self {
@@ -129,7 +131,7 @@ impl From<OwnedHandle> for HandleOrInvalid {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::fs::File {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -145,7 +147,7 @@ impl AsHandle for std::fs::File {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoFd for std::fs::File {
#[inline]
fn into_fd(self) -> OwnedFd {
@@ -153,7 +155,7 @@ impl IntoFd for std::fs::File {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<std::fs::File> for OwnedFd {
#[inline]
fn from(owned: std::fs::File) -> Self {
@@ -177,7 +179,7 @@ impl From<std::fs::File> for OwnedHandle {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromFd for std::fs::File {
#[inline]
fn from_fd(owned: OwnedFd) -> Self {
@@ -185,7 +187,7 @@ impl FromFd for std::fs::File {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<OwnedFd> for std::fs::File {
#[inline]
fn from(owned: OwnedFd) -> Self {
@@ -209,7 +211,7 @@ impl From<OwnedHandle> for std::fs::File {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::net::TcpStream {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -225,7 +227,7 @@ impl AsSocket for std::net::TcpStream {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoFd for std::net::TcpStream {
#[inline]
fn into_fd(self) -> OwnedFd {
@@ -233,7 +235,7 @@ impl IntoFd for std::net::TcpStream {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<std::net::TcpStream> for OwnedFd {
#[inline]
fn from(owned: std::net::TcpStream) -> Self {
@@ -257,7 +259,7 @@ impl From<std::net::TcpStream> for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromFd for std::net::TcpStream {
#[inline]
fn from_fd(owned: OwnedFd) -> Self {
@@ -265,7 +267,7 @@ impl FromFd for std::net::TcpStream {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<OwnedFd> for std::net::TcpStream {
#[inline]
fn from(owned: OwnedFd) -> Self {
@@ -289,7 +291,7 @@ impl From<OwnedSocket> for std::net::TcpStream {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::net::TcpListener {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -305,7 +307,7 @@ impl AsSocket for std::net::TcpListener {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoFd for std::net::TcpListener {
#[inline]
fn into_fd(self) -> OwnedFd {
@@ -313,7 +315,7 @@ impl IntoFd for std::net::TcpListener {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<std::net::TcpListener> for OwnedFd {
#[inline]
fn from(owned: std::net::TcpListener) -> Self {
@@ -337,7 +339,7 @@ impl From<std::net::TcpListener> for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromFd for std::net::TcpListener {
#[inline]
fn from_fd(owned: OwnedFd) -> Self {
@@ -345,7 +347,7 @@ impl FromFd for std::net::TcpListener {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<OwnedFd> for std::net::TcpListener {
#[inline]
fn from(owned: OwnedFd) -> Self {
@@ -369,7 +371,7 @@ impl From<OwnedSocket> for std::net::TcpListener {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::net::UdpSocket {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -385,7 +387,7 @@ impl AsSocket for std::net::UdpSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoFd for std::net::UdpSocket {
#[inline]
fn into_fd(self) -> OwnedFd {
@@ -393,7 +395,7 @@ impl IntoFd for std::net::UdpSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<std::net::UdpSocket> for OwnedFd {
#[inline]
fn from(owned: std::net::UdpSocket) -> Self {
@@ -417,7 +419,7 @@ impl From<std::net::UdpSocket> for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromFd for std::net::UdpSocket {
#[inline]
fn from_fd(owned: OwnedFd) -> Self {
@@ -425,7 +427,7 @@ impl FromFd for std::net::UdpSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl From<OwnedFd> for std::net::UdpSocket {
#[inline]
fn from(owned: OwnedFd) -> Self {
@@ -449,7 +451,7 @@ impl From<OwnedSocket> for std::net::UdpSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::io::Stdin {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -465,7 +467,7 @@ impl AsHandle for std::io::Stdin {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<'a> AsFd for std::io::StdinLock<'a> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -481,7 +483,7 @@ impl<'a> AsHandle for std::io::StdinLock<'a> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::io::Stdout {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -497,7 +499,7 @@ impl AsHandle for std::io::Stdout {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<'a> AsFd for std::io::StdoutLock<'a> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -513,7 +515,7 @@ impl<'a> AsHandle for std::io::StdoutLock<'a> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsFd for std::io::Stderr {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -529,7 +531,7 @@ impl AsHandle for std::io::Stderr {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<'a> AsFd for std::io::StderrLock<'a> {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
diff --git a/vendor/io-lifetimes/src/lib.rs b/vendor/io-lifetimes/src/lib.rs
index d77954133..e293cc589 100644
--- a/vendor/io-lifetimes/src/lib.rs
+++ b/vendor/io-lifetimes/src/lib.rs
@@ -28,10 +28,10 @@
//! [from+into conversions]: FromFilelike::from_into_filelike
#![deny(missing_docs)]
-// Work around https://github.com/rust-lang/rust/issues/103306.
+// Work around <https://github.com/rust-lang/rust/issues/103306>.
#![cfg_attr(all(wasi_ext, target_os = "wasi"), feature(wasi_ext))]
// Currently supported platforms.
-#![cfg(any(unix, windows, target_os = "wasi"))]
+#![cfg(any(unix, windows, target_os = "wasi", target_os = "hermit"))]
mod portability;
mod traits;
@@ -42,12 +42,12 @@ mod types;
mod impls_std;
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub use traits::AsFd;
#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
pub use traits::{AsHandle, AsSocket};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[allow(deprecated)]
pub use traits::{FromFd, IntoFd};
#[cfg(windows)]
@@ -55,7 +55,7 @@ pub use traits::{FromFd, IntoFd};
pub use traits::{FromHandle, FromSocket, IntoHandle, IntoSocket};
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub use types::{BorrowedFd, OwnedFd};
#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
@@ -65,6 +65,9 @@ pub use types::{
};
#[cfg(io_safety_is_in_std)]
+#[cfg(target_os = "hermit")]
+pub use std::os::hermit::io::{AsFd, BorrowedFd, OwnedFd};
+#[cfg(io_safety_is_in_std)]
#[cfg(unix)]
pub use std::os::unix::io::{AsFd, BorrowedFd, OwnedFd};
#[cfg(io_safety_is_in_std)]
@@ -89,7 +92,7 @@ pub use std::os::windows::io::{
// So we define `FromFd`/`IntoFd` traits, and implement them in terms of
// `From`/`Into`,
#[cfg(io_safety_is_in_std)]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[allow(deprecated)]
impl<T: From<OwnedFd>> FromFd for T {
#[inline]
@@ -98,7 +101,7 @@ impl<T: From<OwnedFd>> FromFd for T {
}
}
#[cfg(io_safety_is_in_std)]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[allow(deprecated)]
impl<T> IntoFd for T
where
diff --git a/vendor/io-lifetimes/src/portability.rs b/vendor/io-lifetimes/src/portability.rs
index eb630ce9f..6f6183df7 100644
--- a/vendor/io-lifetimes/src/portability.rs
+++ b/vendor/io-lifetimes/src/portability.rs
@@ -5,7 +5,7 @@
//! layer of portability over this difference.
use crate::views::{FilelikeView, FilelikeViewType, SocketlikeView, SocketlikeViewType};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::{AsFd, BorrowedFd, OwnedFd};
#[cfg(windows)]
use crate::{AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, OwnedHandle, OwnedSocket};
@@ -14,7 +14,7 @@ use crate::{AsHandle, AsSocket, BorrowedHandle, BorrowedSocket, OwnedHandle, Own
///
/// This is a portability abstraction over Unix-like [`BorrowedFd`] and
/// Windows' `BorrowedHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type BorrowedFilelike<'filelike> = BorrowedFd<'filelike>;
/// A reference to a filelike object.
@@ -28,7 +28,7 @@ pub type BorrowedFilelike<'filelike> = BorrowedHandle<'filelike>;
///
/// This is a portability abstraction over Unix-like [`BorrowedFd`] and
/// Windows' `BorrowedSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type BorrowedSocketlike<'socketlike> = BorrowedFd<'socketlike>;
/// A reference to a socketlike object.
@@ -42,7 +42,7 @@ pub type BorrowedSocketlike<'socketlike> = BorrowedSocket<'socketlike>;
///
/// This is a portability abstraction over Unix-like [`OwnedFd`] and
/// Windows' `OwnedHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type OwnedFilelike = OwnedFd;
/// An owned filelike object.
@@ -56,7 +56,7 @@ pub type OwnedFilelike = OwnedHandle;
///
/// This is a portability abstraction over Unix-like [`OwnedFd`] and
/// Windows' `OwnedSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type OwnedSocketlike = OwnedFd;
/// An owned socketlike object.
@@ -71,7 +71,7 @@ pub type OwnedSocketlike = OwnedSocket;
/// This is a portability abstraction over Unix-like [`AsFd`] and Windows'
/// `AsHandle`. It also provides the `as_filelike_view` convenience function
/// providing typed views.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait AsFilelike: AsFd {
/// Borrows the reference.
///
@@ -88,12 +88,13 @@ pub trait AsFilelike: AsFd {
/// ```
fn as_filelike(&self) -> BorrowedFilelike<'_>;
- /// Return a borrowing view of a resource which dereferences to a `&Target`.
+ /// Return a borrowing view of a resource which dereferences to a
+ /// `&Target`.
///
- /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some cases,
- /// such as [`File`], `Read` and `Write` are implemented for `&Target` in
- /// addition to `Target`, and you can get a `&mut &Target` by doing `&*` on
- /// the resuting view, like this:
+ /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some
+ /// cases, such as [`File`], `Read` and `Write` are implemented for
+ /// `&Target` in addition to `Target`, and you can get a `&mut &Target`
+ /// by doing `&*` on the resuting view, like this:
///
/// ```rust,ignore
/// let v = f.as_filelike_view::<std::fs::File>();
@@ -106,7 +107,7 @@ pub trait AsFilelike: AsFd {
fn as_filelike_view<Target: FilelikeViewType>(&self) -> FilelikeView<'_, Target>;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsFd> AsFilelike for T {
#[inline]
fn as_filelike(&self) -> BorrowedFilelike<'_> {
@@ -141,12 +142,13 @@ pub trait AsFilelike: AsHandle {
/// ```
fn as_filelike(&self) -> BorrowedFilelike<'_>;
- /// Return a borrowing view of a resource which dereferences to a `&Target`.
+ /// Return a borrowing view of a resource which dereferences to a
+ /// `&Target`.
///
- /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some cases,
- /// such as [`File`], `Read` and `Write` are implemented for `&Target` in
- /// addition to `Target`, and you can get a `&mut &Target` by doing `&*` on
- /// the resuting view, like this:
+ /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some
+ /// cases, such as [`File`], `Read` and `Write` are implemented for
+ /// `&Target` in addition to `Target`, and you can get a `&mut &Target`
+ /// by doing `&*` on the resuting view, like this:
///
/// ```rust,ignore
/// let v = f.as_filelike_view::<std::fs::File>();
@@ -178,17 +180,18 @@ impl<T: AsHandle> AsFilelike for T {
/// This is a portability abstraction over Unix-like [`AsFd`] and Windows'
/// `AsSocket`. It also provides the `as_socketlike_view` convenience
/// function providing typed views.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait AsSocketlike: AsFd {
/// Borrows the reference.
fn as_socketlike(&self) -> BorrowedSocketlike<'_>;
- /// Return a borrowing view of a resource which dereferences to a `&Target`.
+ /// Return a borrowing view of a resource which dereferences to a
+ /// `&Target`.
///
- /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some cases,
- /// such as [`TcpStream`], `Read` and `Write` are implemented for `&Target` in
- /// addition to `Target`, and you can get a `&mut &Target` by doing `&*` on
- /// the resuting view, like this:
+ /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some
+ /// cases, such as [`TcpStream`], `Read` and `Write` are implemented
+ /// for `&Target` in addition to `Target`, and you can get a `&mut
+ /// &Target` by doing `&*` on the resuting view, like this:
///
/// ```rust,ignore
/// let v = s.as_socketlike_view::<std::net::TcpStream>();
@@ -201,7 +204,7 @@ pub trait AsSocketlike: AsFd {
fn as_socketlike_view<Target: SocketlikeViewType>(&self) -> SocketlikeView<'_, Target>;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsFd> AsSocketlike for T {
#[inline]
fn as_socketlike(&self) -> BorrowedSocketlike<'_> {
@@ -225,12 +228,13 @@ pub trait AsSocketlike: AsSocket {
/// Borrows the reference.
fn as_socketlike(&self) -> BorrowedSocketlike;
- /// Return a borrowing view of a resource which dereferences to a `&Target`.
+ /// Return a borrowing view of a resource which dereferences to a
+ /// `&Target`.
///
- /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some cases,
- /// such as [`TcpStream`], `Read` and `Write` are implemented for `&Target` in
- /// addition to `Target`, and you can get a `&mut &Target` by doing `&*` on
- /// the resuting view, like this:
+ /// Note that [`Read`] or [`Write`] require `&mut Target`, but in some
+ /// cases, such as [`TcpStream`], `Read` and `Write` are implemented
+ /// for `&Target` in addition to `Target`, and you can get a `&mut
+ /// &Target` by doing `&*` on the resuting view, like this:
///
/// ```rust,ignore
/// let v = s.as_socketlike_view::<std::net::TcpStream>();
@@ -257,9 +261,9 @@ 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 [`Into<OwnedFd>`] and Windows'
-/// `Into<OwnedHandle>`.
-#[cfg(any(unix, target_os = "wasi"))]
+/// This is a portability abstraction over Unix-like [`Into<OwnedFd>`] and
+/// Windows' `Into<OwnedHandle>`.
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait IntoFilelike: Into<OwnedFd> {
/// Consumes this object, returning the underlying filelike object.
///
@@ -277,7 +281,7 @@ pub trait IntoFilelike: Into<OwnedFd> {
fn into_filelike(self) -> OwnedFilelike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: Into<OwnedFd>> IntoFilelike for T {
#[inline]
fn into_filelike(self) -> OwnedFilelike {
@@ -288,8 +292,8 @@ impl<T: Into<OwnedFd>> IntoFilelike 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 `Into<OwnedFd>` and Windows'
-/// [`Into<OwnedHandle>`].
+/// This is a portability abstraction over Unix-like `Into<OwnedFd>` and
+/// Windows' [`Into<OwnedHandle>`].
#[cfg(windows)]
pub trait IntoFilelike: Into<OwnedHandle> {
/// Consumes this object, returning the underlying filelike object.
@@ -307,15 +311,15 @@ impl<T: Into<OwnedHandle>> IntoFilelike for T {
/// 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 [`Into<OwnedFd>`] and Windows'
-/// `Into<OwnedSocket>`.
-#[cfg(any(unix, target_os = "wasi"))]
+/// This is a portability abstraction over Unix-like [`Into<OwnedFd>`] and
+/// Windows' `Into<OwnedSocket>`.
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait IntoSocketlike: Into<OwnedFd> {
/// Consumes this object, returning the underlying socketlike object.
fn into_socketlike(self) -> OwnedSocketlike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: Into<OwnedFd>> IntoSocketlike for T {
#[inline]
fn into_socketlike(self) -> OwnedSocketlike {
@@ -326,8 +330,8 @@ impl<T: Into<OwnedFd>> IntoSocketlike for T {
/// 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 `Into<OwnedFd>` and Windows'
-/// [`Into<OwnedSocket>`].
+/// This is a portability abstraction over Unix-like `Into<OwnedFd>` and
+/// Windows' [`Into<OwnedSocket>`].
#[cfg(windows)]
pub trait IntoSocketlike: Into<OwnedSocket> {
/// Consumes this object, returning the underlying socketlike object.
@@ -357,10 +361,10 @@ impl<T: Into<OwnedSocket>> IntoSocketlike 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 [`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"))]
+/// 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", target_os = "hermit"))]
pub trait FromFilelike: From<OwnedFd> {
/// Constructs a new instance of `Self` from the given filelike object.
///
@@ -395,7 +399,7 @@ pub trait FromFilelike: From<OwnedFd> {
fn from_into_filelike<Owned: IntoFilelike>(owned: Owned) -> Self;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: From<OwnedFd>> FromFilelike for T {
#[inline]
fn from_filelike(owned: OwnedFilelike) -> Self {
@@ -411,9 +415,9 @@ impl<T: From<OwnedFd>> 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 `From<OwnedFd>` and Windows'
-/// [`From<OwnedHandle>`]. It also provides the `from_into_filelike` convenience
-/// function providing simplified from+into conversions.
+/// 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: From<OwnedHandle> {
/// Constructs a new instance of `Self` from the given filelike object.
@@ -465,10 +469,11 @@ impl<T: From<OwnedHandle>> 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 [`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"))]
+/// 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", target_os = "hermit"))]
pub trait FromSocketlike: From<OwnedFd> {
/// Constructs a new instance of `Self` from the given socketlike object.
fn from_socketlike(owned: OwnedSocketlike) -> Self;
@@ -478,7 +483,7 @@ pub trait FromSocketlike: From<OwnedFd> {
fn from_into_socketlike<Owned: IntoSocketlike>(owned: Owned) -> Self;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: From<OwnedFd>> FromSocketlike for T {
#[inline]
fn from_socketlike(owned: OwnedSocketlike) -> Self {
@@ -494,9 +499,9 @@ impl<T: From<OwnedFd>> 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 `From<OwnedFd>` and Windows'
-/// [`From<OwnedSocket>`]. It also provides the `from_into_socketlike` convenience
-/// function providing simplified from+into conversions.
+/// 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: From<OwnedSocket> {
/// Constructs a new instance of `Self` from the given socketlike object.
diff --git a/vendor/io-lifetimes/src/raw.rs b/vendor/io-lifetimes/src/raw.rs
index 0264f4084..8642a8e28 100644
--- a/vendor/io-lifetimes/src/raw.rs
+++ b/vendor/io-lifetimes/src/raw.rs
@@ -4,6 +4,8 @@
//! handles are distinct from socket descriptors. This file provides a minimal
//! layer of portability over this difference.
+#[cfg(target_os = "hermit")]
+use std::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(target_os = "wasi")]
@@ -18,7 +20,7 @@ use std::os::windows::io::{
///
/// This is a portability abstraction over Unix-like [`RawFd`] and
/// Windows' `RawHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type RawFilelike = RawFd;
/// A raw filelike object.
@@ -32,7 +34,7 @@ pub type RawFilelike = RawHandle;
///
/// This is a portability abstraction over Unix-like [`RawFd`] and
/// Windows' `RawSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub type RawSocketlike = RawFd;
/// A raw socketlike object.
@@ -46,13 +48,13 @@ pub type RawSocketlike = RawSocket;
///
/// This is a portability abstraction over Unix-like [`AsRawFd`] and Windows'
/// `AsRawHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait AsRawFilelike: AsRawFd {
/// Returns the raw value.
fn as_raw_filelike(&self) -> RawFilelike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsRawFd> AsRawFilelike for T {
#[inline]
fn as_raw_filelike(&self) -> RawFilelike {
@@ -78,13 +80,13 @@ impl<T: AsRawHandle> AsRawFilelike for T {
/// This is a portability abstraction over Unix-like [`AsRawFd`] and Windows'
/// `AsRawSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait AsRawSocketlike: AsRawFd {
/// Returns the raw value.
fn as_raw_socketlike(&self) -> RawSocketlike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsRawFd> AsRawSocketlike for T {
#[inline]
fn as_raw_socketlike(&self) -> RawSocketlike {
@@ -110,13 +112,13 @@ impl<T: AsRawSocket> AsRawSocketlike for T {
/// This is a portability abstraction over Unix-like [`IntoRawFd`] and Windows'
/// `IntoRawHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait IntoRawFilelike: IntoRawFd {
/// Returns the raw value.
fn into_raw_filelike(self) -> RawFilelike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: IntoRawFd> IntoRawFilelike for T {
#[inline]
fn into_raw_filelike(self) -> RawFilelike {
@@ -142,13 +144,13 @@ impl<T: IntoRawHandle> IntoRawFilelike for T {
/// This is a portability abstraction over Unix-like [`IntoRawFd`] and Windows'
/// `IntoRawSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait IntoRawSocketlike: IntoRawFd {
/// Returns the raw value.
fn into_raw_socketlike(self) -> RawSocketlike;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: IntoRawFd> IntoRawSocketlike for T {
#[inline]
fn into_raw_socketlike(self) -> RawSocketlike {
@@ -174,7 +176,7 @@ impl<T: IntoRawSocket> IntoRawSocketlike for T {
/// This is a portability abstraction over Unix-like [`FromRawFd`] and Windows'
/// `FromRawHandle`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait FromRawFilelike: FromRawFd {
/// Constructs `Self` from the raw value.
///
@@ -183,12 +185,12 @@ pub trait FromRawFilelike: FromRawFd {
/// This is `unsafe` for the same reason as [`from_raw_fd`] and
/// [`from_raw_handle`].
///
- /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd
+ /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.from_raw_fd
/// [`from_raw_handle`]: https://doc.rust-lang.org/stable/std/os/windows/io/trait.FromRawHandle.html#tymethod.from_raw_handle
unsafe fn from_raw_filelike(raw: RawFilelike) -> Self;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: FromRawFd> FromRawFilelike for T {
#[inline]
unsafe fn from_raw_filelike(raw: RawFilelike) -> Self {
@@ -214,7 +216,7 @@ impl<T: FromRawHandle> FromRawFilelike for T {
/// This is a portability abstraction over Unix-like [`FromRawFd`] and Windows'
/// `FromRawSocket`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait FromRawSocketlike: FromRawFd {
/// Constructs `Self` from the raw value.
///
@@ -223,12 +225,12 @@ pub trait FromRawSocketlike: FromRawFd {
/// This is `unsafe` for the same reason as [`from_raw_fd`] and
/// [`from_raw_socket`].
///
- /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd
+ /// [`from_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.from_raw_fd
/// [`from_raw_socket`]: https://doc.rust-lang.org/stable/std/os/windows/io/trait.FromRawSocket.html#tymethod.from_raw_socket
unsafe fn from_raw_socketlike(raw: RawSocketlike) -> Self;
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: FromRawFd> FromRawSocketlike for T {
#[inline]
unsafe fn from_raw_socketlike(raw: RawSocketlike) -> Self {
diff --git a/vendor/io-lifetimes/src/traits.rs b/vendor/io-lifetimes/src/traits.rs
index 7fb9a5bdb..b02573106 100644
--- a/vendor/io-lifetimes/src/traits.rs
+++ b/vendor/io-lifetimes/src/traits.rs
@@ -1,7 +1,7 @@
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::BorrowedFd;
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::OwnedFd;
#[cfg(not(io_safety_is_in_std))]
#[cfg(windows)]
@@ -15,7 +15,7 @@ use crate::{OwnedHandle, OwnedSocket};
/// call the method. Windows platforms have a corresponding `AsHandle` and
/// `AsSocket` set of traits.
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait AsFd {
/// Borrows the file descriptor.
///
@@ -63,7 +63,7 @@ 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"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[deprecated(
since = "1.0.0",
note = "`IntoFd` is replaced by `From<...> for OwnedFd` or `Into<OwnedFd>`"
@@ -123,7 +123,7 @@ pub trait IntoSocket {
/// A trait to express the ability to construct an object from a file
/// descriptor.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
pub trait FromFd {
/// Constructs a new instance of `Self` from the given file descriptor.
///
@@ -236,7 +236,7 @@ pub trait FromSocket {
}
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsFd> AsFd for &T {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
@@ -245,7 +245,7 @@ impl<T: AsFd> AsFd for &T {
}
#[cfg(not(io_safety_is_in_std))]
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl<T: AsFd> AsFd for &mut T {
#[inline]
fn as_fd(&self) -> BorrowedFd<'_> {
diff --git a/vendor/io-lifetimes/src/types.rs b/vendor/io-lifetimes/src/types.rs
index 7f7809fb0..8d640dc3b 100644
--- a/vendor/io-lifetimes/src/types.rs
+++ b/vendor/io-lifetimes/src/types.rs
@@ -1,6 +1,8 @@
use std::fmt;
use std::marker::PhantomData;
use std::mem::forget;
+#[cfg(target_os = "hermit")]
+use std::os::hermit::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(target_os = "wasi")]
@@ -47,7 +49,7 @@ const INVALID_SOCKET: usize = !0 as _;
/// This type's `.to_owned()` implementation returns another `BorrowedFd`
/// rather than an `OwnedFd`. It just makes a trivial copy of the raw file
/// descriptor, which is then borrowed under the same lifetime.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct BorrowedFd<'fd> {
@@ -112,13 +114,13 @@ pub struct BorrowedSocket<'socket> {
/// descriptor, so it can be used in FFI in places where a file descriptor is
/// passed as a consumed argument or returned as an owned value, and it never
/// has the value `-1`.
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
#[repr(transparent)]
pub struct OwnedFd {
fd: RawFd,
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl OwnedFd {
/// Creates a new `OwnedFd` instance that shares the same underlying file
/// description as the existing `OwnedFd` instance.
@@ -127,7 +129,7 @@ impl OwnedFd {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl BorrowedFd<'_> {
/// Creates a new `OwnedFd` instance that shares the same underlying file
/// description as the existing `BorrowedFd` instance.
@@ -157,7 +159,7 @@ impl BorrowedFd<'_> {
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
}
- #[cfg(target_os = "wasi")]
+ #[cfg(any(target_os = "wasi", target_os = "hermit"))]
{
unreachable!("try_clone is not yet suppported on wasi");
}
@@ -289,9 +291,9 @@ impl OwnedSocket {
#[cfg(feature = "close")]
#[cfg(target_vendor = "uwp")]
fn set_no_inherit(&self) -> std::io::Result<()> {
- Err(io::Error::new_const(
+ Err(std::io::Error::new(
std::io::ErrorKind::Unsupported,
- &"Unavailable on UWP",
+ "Unavailable on UWP",
))
}
}
@@ -427,7 +429,7 @@ unsafe impl Sync for HandleOrNull {}
#[cfg(windows)]
unsafe impl Sync for BorrowedHandle<'_> {}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl BorrowedFd<'_> {
/// Return a `BorrowedFd` holding the given raw file descriptor.
///
@@ -558,7 +560,7 @@ impl fmt::Display for InvalidHandleError {
impl std::error::Error for InvalidHandleError {}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsRawFd for BorrowedFd<'_> {
#[inline]
fn as_raw_fd(&self) -> RawFd {
@@ -582,7 +584,7 @@ impl AsRawSocket for BorrowedSocket<'_> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl AsRawFd for OwnedFd {
#[inline]
fn as_raw_fd(&self) -> RawFd {
@@ -606,7 +608,7 @@ impl AsRawSocket for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl IntoRawFd for OwnedFd {
#[inline]
fn into_raw_fd(self) -> RawFd {
@@ -636,7 +638,7 @@ impl IntoRawSocket for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl FromRawFd for OwnedFd {
/// Constructs a new instance of `Self` from the given raw file descriptor.
///
@@ -731,6 +733,24 @@ impl Drop for OwnedFd {
}
}
+#[cfg(target_os = "hermit")]
+impl Drop for OwnedFd {
+ #[inline]
+ fn drop(&mut self) {
+ #[cfg(feature = "close")]
+ unsafe {
+ let _ = hermit_abi::close(self.fd);
+ }
+
+ // If the `close` feature is disabled, we expect users to avoid letting
+ // `OwnedFd` instances drop, so that we don't have to call `close`.
+ #[cfg(not(feature = "close"))]
+ {
+ unreachable!("drop called without the \"close\" feature in io-lifetimes");
+ }
+ }
+}
+
#[cfg(windows)]
impl Drop for OwnedHandle {
#[inline]
@@ -803,7 +823,7 @@ impl Drop for OwnedSocket {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl fmt::Debug for BorrowedFd<'_> {
#[allow(clippy::missing_inline_in_public_items)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -831,7 +851,7 @@ impl fmt::Debug for BorrowedSocket<'_> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
impl fmt::Debug for OwnedFd {
#[allow(clippy::missing_inline_in_public_items)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/vendor/io-lifetimes/src/views.rs b/vendor/io-lifetimes/src/views.rs
index b74a8c387..86315da08 100644
--- a/vendor/io-lifetimes/src/views.rs
+++ b/vendor/io-lifetimes/src/views.rs
@@ -9,7 +9,7 @@ use crate::raw::{
AsRawFilelike, AsRawSocketlike, FromRawFilelike, FromRawSocketlike, IntoRawFilelike,
IntoRawSocketlike, RawFilelike, RawSocketlike,
};
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
use crate::OwnedFd;
use crate::{
AsFilelike, AsSocketlike, FromFilelike, FromSocketlike, IntoFilelike, IntoSocketlike,
@@ -207,7 +207,7 @@ impl<Target: SocketlikeViewType> fmt::Debug for SocketlikeView<'_, Target> {
}
}
-#[cfg(any(unix, target_os = "wasi"))]
+#[cfg(any(unix, target_os = "wasi", target_os = "hermit"))]
unsafe impl FilelikeViewType for OwnedFd {}
#[cfg(windows)]
unsafe impl FilelikeViewType for OwnedHandle {}
@@ -224,24 +224,24 @@ 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(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "os_pipe")]
unsafe impl FilelikeViewType for os_pipe::PipeWriter {}
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "os_pipe")]
unsafe impl FilelikeViewType for os_pipe::PipeReader {}
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "socket2")]
unsafe impl SocketlikeViewType for socket2::Socket {}
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "async_std")]
unsafe impl SocketlikeViewType for async_std::net::TcpStream {}
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "async_std")]
unsafe impl SocketlikeViewType for async_std::net::TcpListener {}
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_os = "hermit")))]
#[cfg(feature = "async_std")]
unsafe impl SocketlikeViewType for async_std::net::UdpSocket {}
#[cfg(unix)]