From 6bb3265e467452ee4f6f04e6217854e441c91fab Mon Sep 17 00:00:00 2001 From: Oakchris1955 <80592203+Oakchris1955@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:32:25 +0300 Subject: [PATCH] io: Expand embedded_io::ErrorKind to better match std::io::ErrorKind --- embedded-io/src/lib.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/embedded-io/src/lib.rs b/embedded-io/src/lib.rs index a0d5b1a1..fbd405da 100644 --- a/embedded-io/src/lib.rs +++ b/embedded-io/src/lib.rs @@ -114,6 +114,26 @@ pub enum ErrorKind { OutOfMemory, /// An attempted write could not write any data. WriteZero, + /// The filesystem or storage medium is read-only, + /// but a write operation was attempted. + ReadOnlyFilesystem, + /// The underlying storage (typically, a filesystem) is full. + /// + /// This does not include out of quota errors. + StorageFull, + /// Seek on unseekable file. + /// + /// Seeking was attempted on an open file handle + /// which is not suitable for seeking + NotSeekable, + /// Filesystem quota or some other kind of quota was exceeded. + QuotaExceeded, + /// File larger than allowed or supported. + /// + /// This might arise from a hard limit of the underlying filesystem or + /// file access API, or from an administratively imposed resource limitation. + /// Simple disk full, and out of quota, have their own errors. + FileTooLarge, } #[cfg(feature = "std")] @@ -137,6 +157,11 @@ impl From for std::io::ErrorKind { ErrorKind::Interrupted => std::io::ErrorKind::Interrupted, ErrorKind::Unsupported => std::io::ErrorKind::Unsupported, ErrorKind::OutOfMemory => std::io::ErrorKind::OutOfMemory, + ErrorKind::ReadOnlyFilesystem => std::io::ErrorKind::ReadOnlyFilesystem, + ErrorKind::StorageFull => std::io::ErrorKind::StorageFull, + ErrorKind::NotSeekable => std::io::ErrorKind::NotSeekable, + ErrorKind::QuotaExceeded => std::io::ErrorKind::QuotaExceeded, + ErrorKind::FileTooLarge => std::io::ErrorKind::FileTooLarge, _ => std::io::ErrorKind::Other, } } @@ -163,6 +188,11 @@ impl From for ErrorKind { std::io::ErrorKind::Interrupted => ErrorKind::Interrupted, std::io::ErrorKind::Unsupported => ErrorKind::Unsupported, std::io::ErrorKind::OutOfMemory => ErrorKind::OutOfMemory, + std::io::ErrorKind::ReadOnlyFilesystem => ErrorKind::ReadOnlyFilesystem, + std::io::ErrorKind::StorageFull => ErrorKind::StorageFull, + std::io::ErrorKind::NotSeekable => ErrorKind::NotSeekable, + std::io::ErrorKind::QuotaExceeded => ErrorKind::QuotaExceeded, + std::io::ErrorKind::FileTooLarge => ErrorKind::FileTooLarge, _ => ErrorKind::Other, } }