summaryrefslogtreecommitdiffstats
path: root/vendor/io-lifetimes
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/io-lifetimes')
-rw-r--r--vendor/io-lifetimes/.cargo-checksum.json2
-rw-r--r--vendor/io-lifetimes/Cargo.toml9
-rw-r--r--vendor/io-lifetimes/README.md4
-rw-r--r--vendor/io-lifetimes/build.rs93
-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
12 files changed, 235 insertions, 196 deletions
diff --git a/vendor/io-lifetimes/.cargo-checksum.json b/vendor/io-lifetimes/.cargo-checksum.json
index d9c453178..9fc1b74ff 100644
--- a/vendor/io-lifetimes/.cargo-checksum.json
+++ b/vendor/io-lifetimes/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CODE_OF_CONDUCT.md":"e0bd80144c93b032dadb144d7cf8663c55d697ba2dd60382715c981dfc60e421","COPYRIGHT":"495c30b45120f8af07cfa26eb9cb1ebfe8324560dca2b3b1e76cad1b9b6b489a","Cargo.toml":"250de4b507a7eb89bf97fdcea7b2511020d28c5919de5ab12fb8d91d5ba98247","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-Apache-2.0_WITH_LLVM-exception":"268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","ORG_CODE_OF_CONDUCT.md":"a62b69bf86e605ee1bcbb2f0a12ba79e4cebb6983a7b6491949750aecc4f2178","README.md":"408d5965c87cc338493f67f638adea97dbd415f4e12638be1365096afa2b8ba3","build.rs":"5809e0c02e95c4e7ddc57a07090b7ae2254cbe1aef493c9a2d720c58e4424556","src/example_ffi.rs":"c369438f2c44b21a5b977d303d6d0f3069a44d56d8ef770da06ddc3dcc967bdf","src/impls_async_std.rs":"62f73e42a2e76a9287f72f1c3db322114d4a08a2d8e2715c04156df60df1f876","src/impls_fs_err.rs":"12333298a291377a8c24835c60dfa3338e413e6435576cede04ce780da84ebe6","src/impls_mio.rs":"32ba71c1912d7dedcb110cb91dd953bab05a039d576c55a7508fcdad1bebbc2b","src/impls_os_pipe.rs":"5075498711f2dfdd6795d3afdb81bd3aca26c033d2f8f7238de59016d3ead0a9","src/impls_socket2.rs":"deacb4dd2c1e19ef483c937b6a18034397d729c3df361de5e748d70f5457f48b","src/impls_std.rs":"4e73f3993f539b7fa22db0b878eb8845d9ecf79f1580382619c83e18cf384fa3","src/impls_tokio.rs":"4f5f3dbdfa9395cd7e5149658cbd3872fa6c3973e1c844b7f6b48ee2e39e9197","src/lib.rs":"2dc8f7bcad5d12ce5d60c9db9a7780bead0240baeaca8d8cfd1d531c14e8eec4","src/portability.rs":"3e9929c7c04524d99a481c646f708f29cd5e251bf44dad7115ae381c2bcaab78","src/raw.rs":"2fa1ea37da1cc993e36ce7950b3e2bc635b3ac268dacd5b5520e5bfc84741b4a","src/traits.rs":"7419b21302b5a633dddf6765af706c5c09840a55e004d839f418fdb5f8826b2b","src/types.rs":"ca3729538bcfd3f63379fd1db4cb635b84cc1380d96ec5072403570de062df9c","src/views.rs":"ecc38c14b08566cc1667d530804a86124d90480e7fdecc585b0e4cfff7312807"},"package":"46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c"} \ No newline at end of file
+{"files":{"CODE_OF_CONDUCT.md":"e0bd80144c93b032dadb144d7cf8663c55d697ba2dd60382715c981dfc60e421","COPYRIGHT":"495c30b45120f8af07cfa26eb9cb1ebfe8324560dca2b3b1e76cad1b9b6b489a","Cargo.toml":"1f84b8c1b7b42968671bcdbba31196831a95035cc95c3e5c73a65d3dc89fcc96","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-Apache-2.0_WITH_LLVM-exception":"268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","ORG_CODE_OF_CONDUCT.md":"a62b69bf86e605ee1bcbb2f0a12ba79e4cebb6983a7b6491949750aecc4f2178","README.md":"c6fd1e6acd03d78ca69275d3fb7fe27b7148ff62e11e617eec25e3a886caf082","build.rs":"58379e213e1758e25de92a04a1a6b3feb283321c3652e2271fc688879320147c","src/example_ffi.rs":"c9db4344e2d4b01a7310b05174c88e1933e367037c862fc192a4ee5d9166ae7e","src/impls_async_std.rs":"62f73e42a2e76a9287f72f1c3db322114d4a08a2d8e2715c04156df60df1f876","src/impls_fs_err.rs":"12333298a291377a8c24835c60dfa3338e413e6435576cede04ce780da84ebe6","src/impls_mio.rs":"32ba71c1912d7dedcb110cb91dd953bab05a039d576c55a7508fcdad1bebbc2b","src/impls_os_pipe.rs":"5075498711f2dfdd6795d3afdb81bd3aca26c033d2f8f7238de59016d3ead0a9","src/impls_socket2.rs":"deacb4dd2c1e19ef483c937b6a18034397d729c3df361de5e748d70f5457f48b","src/impls_std.rs":"d11c66589a19b431062c316eaa77e1648e73aacd4ffabf9f575e5ccd2dec4083","src/impls_tokio.rs":"4f5f3dbdfa9395cd7e5149658cbd3872fa6c3973e1c844b7f6b48ee2e39e9197","src/lib.rs":"ca2d5187b1c25c21c18dc2e81988d6b7fda54d60a431802c2e53caef62d0814d","src/portability.rs":"d01be95b82bd36e09cf196a7c5f596a3d64c947aca34224efff164c87f358bcf","src/raw.rs":"16ff59fcc9ed2e08df56de40e25337bfe929bf77ec69ff4742902f39af8cc968","src/traits.rs":"e4856985681aad7bdd9c3cbb84a20c7233e1daa242220a82ee10514474fa05c7","src/types.rs":"88eb942b05bcaa7858e8949763031ba69fca5fad01aee4ea43fafa4448ce0654","src/views.rs":"a13342880bed2af759829ba4a5cf2502ef781612138c447820eb36da9450a843"},"package":"09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb"} \ No newline at end of file
diff --git a/vendor/io-lifetimes/Cargo.toml b/vendor/io-lifetimes/Cargo.toml
index 3f578ab6c..6d12b401b 100644
--- a/vendor/io-lifetimes/Cargo.toml
+++ b/vendor/io-lifetimes/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "io-lifetimes"
-version = "1.0.3"
+version = "1.0.9"
authors = ["Dan Gohman <dev@sunfishcode.online>"]
include = [
"src",
@@ -42,6 +42,7 @@ optional = true
[features]
close = [
"libc",
+ "hermit-abi",
"windows-sys",
]
default = ["close"]
@@ -81,8 +82,12 @@ optional = true
version = "0.2.96"
optional = true
+[target."cfg(target_os = \"hermit\")".dependencies.hermit-abi]
+version = "0.3"
+optional = true
+
[target."cfg(windows)".dependencies.windows-sys]
-version = "0.42.0"
+version = "0.45.0"
features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
diff --git a/vendor/io-lifetimes/README.md b/vendor/io-lifetimes/README.md
index db22b0ded..589612112 100644
--- a/vendor/io-lifetimes/README.md
+++ b/vendor/io-lifetimes/README.md
@@ -174,6 +174,6 @@ currently Rust 1.48. This policy may change in the future, in minor version
releases, so users using a fixed version of Rust should pin to a specific
version of this crate.
-[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.OwnedFd.html
-[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html
+[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html
+[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/fd/struct.BorrowedFd.html
[RFC 3128]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
diff --git a/vendor/io-lifetimes/build.rs b/vendor/io-lifetimes/build.rs
index fd3c6ccce..2fc2a3817 100644
--- a/vendor/io-lifetimes/build.rs
+++ b/vendor/io-lifetimes/build.rs
@@ -8,7 +8,7 @@ fn main() {
}
// Work around
- // https://github.com/rust-lang/rust/issues/103306.
+ // <https://github.com/rust-lang/rust/issues/103306>.
use_feature_or_nothing("wasi_ext");
// Rust 1.56 and earlier don't support panic in const fn.
@@ -33,70 +33,72 @@ fn use_feature(feature: &str) {
/// Test whether the rustc at `var("RUSTC")` supports the given feature.
fn has_feature(feature: &str) -> bool {
+ can_compile(format!(
+ "#![allow(stable_features)]\n#![feature({})]",
+ feature
+ ))
+}
+
+/// Test whether the rustc at `var("RUSTC")` can compile the given code.
+fn can_compile<T: AsRef<str>>(test: T) -> bool {
+ use std::process::Stdio;
+
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();
- let mut child = std::process::Command::new(rustc)
- .arg("--crate-type=rlib") // Don't require `main`.
+ // Use `RUSTC_WRAPPER` if it's set, unless it's set to an empty string,
+ // as documented [here].
+ // [here]: https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-reads
+ let wrapper = var("RUSTC_WRAPPER")
+ .ok()
+ .and_then(|w| if w.is_empty() { None } else { Some(w) });
+
+ let mut cmd = if let Some(wrapper) = wrapper {
+ let mut cmd = std::process::Command::new(wrapper);
+ // The wrapper's first argument is supposed to be the path to rustc.
+ cmd.arg(rustc);
+ cmd
+ } else {
+ std::process::Command::new(rustc)
+ };
+
+ cmd.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
- .arg(out_dir) // Put the output somewhere inconsequential.
+ .arg(out_dir); // Put the output somewhere inconsequential.
+
+ // If Cargo wants to set RUSTFLAGS, use that.
+ if let Ok(rustflags) = var("CARGO_ENCODED_RUSTFLAGS") {
+ if !rustflags.is_empty() {
+ for arg in rustflags.split('\x1f') {
+ cmd.arg(arg);
+ }
+ }
+ }
+
+ let mut child = cmd
.arg("-") // Read from stdin.
- .stdin(std::process::Stdio::piped()) // Stdin is a pipe.
+ .stdin(Stdio::piped()) // Stdin is a pipe.
+ .stderr(Stdio::null()) // Errors from feature detection aren't interesting and can be confusing.
.spawn()
.unwrap();
- writeln!(child.stdin.take().unwrap(), "#![feature({})]", feature).unwrap();
+ writeln!(child.stdin.take().unwrap(), "{}", test.as_ref()).unwrap();
child.wait().unwrap().success()
}
/// Test whether the rustc at `var("RUSTC")` supports panic in `const fn`.
fn has_panic_in_const_fn() -> bool {
- let out_dir = var("OUT_DIR").unwrap();
- let rustc = var("RUSTC").unwrap();
- let target = var("TARGET").unwrap();
-
- let mut child = std::process::Command::new(rustc)
- .arg("--crate-type=rlib") // Don't require `main`.
- .arg("--emit=metadata") // Do as little as possible but still parse.
- .arg("--target")
- .arg(target)
- .arg("--out-dir")
- .arg(out_dir) // Put the output somewhere inconsequential.
- .arg("-") // Read from stdin.
- .stdin(std::process::Stdio::piped()) // Stdin is a pipe.
- .spawn()
- .unwrap();
-
- writeln!(child.stdin.take().unwrap(), "const fn foo() {{ panic!() }}").unwrap();
-
- child.wait().unwrap().success()
+ can_compile("const fn foo() {{ panic!() }}")
}
/// Test whether the rustc at `var("RUSTC")` supports the I/O safety feature.
fn has_io_safety() -> bool {
- let out_dir = var("OUT_DIR").unwrap();
- let rustc = var("RUSTC").unwrap();
- let target = var("TARGET").unwrap();
-
- let mut child = std::process::Command::new(rustc)
- .arg("--crate-type=rlib") // Don't require `main`.
- .arg("--emit=metadata") // Do as little as possible but still parse.
- .arg("--target")
- .arg(target)
- .arg("--out-dir")
- .arg(out_dir) // Put the output somewhere inconsequential.
- .arg("-") // Read from stdin.
- .stdin(std::process::Stdio::piped()) // Stdin is a pipe.
- .spawn()
- .unwrap();
-
- writeln!(
- child.stdin.take().unwrap(),
+ can_compile(
"\
#[cfg(unix)]\n\
use std::os::unix::io::OwnedFd as Owned;\n\
@@ -106,9 +108,6 @@ fn has_io_safety() -> bool {
use std::os::windows::io::OwnedHandle as Owned;\n\
\n\
pub type Success = Owned;\n\
- "
+ ",
)
- .unwrap();
-
- child.wait().unwrap().success()
}
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)]