From c86f1ce711bdc1c9ca8201aac6ffff08dd45450b Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Tue, 24 Sep 2024 18:52:54 +0300 Subject: [PATCH] add InProgress ErrorKind gated behind io_error_inprogress feature Co-authored-by: David Tolnay Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com> --- std/src/io/error.rs | 6 ++++++ std/src/io/error/repr_bitpacked.rs | 1 + std/src/sys/pal/unix/mod.rs | 1 + 3 files changed, 8 insertions(+) diff --git a/std/src/io/error.rs b/std/src/io/error.rs index 6ecd9469c1740..795cc64e957da 100644 --- a/std/src/io/error.rs +++ b/std/src/io/error.rs @@ -400,6 +400,11 @@ pub enum ErrorKind { #[stable(feature = "out_of_memory_error", since = "1.54.0")] OutOfMemory, + /// The operation was partially successful and needs to be checked + /// later on due to not blocking. + #[unstable(feature = "io_error_inprogress", issue = "none")] + InProgress, + // "Unusual" error kinds which do not correspond simply to (sets // of) OS error codes, should be added just above this comment. // `Other` and `Uncategorized` should remain at the end: @@ -449,6 +454,7 @@ impl ErrorKind { FilesystemQuotaExceeded => "filesystem quota exceeded", HostUnreachable => "host unreachable", Interrupted => "operation interrupted", + InProgress => "in progress", InvalidData => "invalid data", InvalidFilename => "invalid filename", InvalidInput => "invalid input parameter", diff --git a/std/src/io/error/repr_bitpacked.rs b/std/src/io/error/repr_bitpacked.rs index 9d3ade46bd929..80ba8455df347 100644 --- a/std/src/io/error/repr_bitpacked.rs +++ b/std/src/io/error/repr_bitpacked.rs @@ -348,6 +348,7 @@ fn kind_from_prim(ek: u32) -> Option { UnexpectedEof, Unsupported, OutOfMemory, + InProgress, Uncategorized, }) } diff --git a/std/src/sys/pal/unix/mod.rs b/std/src/sys/pal/unix/mod.rs index 1c9159e5fba86..0d63b1119d59a 100644 --- a/std/src/sys/pal/unix/mod.rs +++ b/std/src/sys/pal/unix/mod.rs @@ -279,6 +279,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::ETIMEDOUT => TimedOut, libc::ETXTBSY => ExecutableFileBusy, libc::EXDEV => CrossesDevices, + libc::EINPROGRESS => InProgress, libc::EACCES | libc::EPERM => PermissionDenied,