Skip to content

Commit 6bb3265

Browse files
committed
io: Expand embedded_io::ErrorKind to better match std::io::ErrorKind
1 parent e12dbf6 commit 6bb3265

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

embedded-io/src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ pub enum ErrorKind {
114114
OutOfMemory,
115115
/// An attempted write could not write any data.
116116
WriteZero,
117+
/// The filesystem or storage medium is read-only,
118+
/// but a write operation was attempted.
119+
ReadOnlyFilesystem,
120+
/// The underlying storage (typically, a filesystem) is full.
121+
///
122+
/// This does not include out of quota errors.
123+
StorageFull,
124+
/// Seek on unseekable file.
125+
///
126+
/// Seeking was attempted on an open file handle
127+
/// which is not suitable for seeking
128+
NotSeekable,
129+
/// Filesystem quota or some other kind of quota was exceeded.
130+
QuotaExceeded,
131+
/// File larger than allowed or supported.
132+
///
133+
/// This might arise from a hard limit of the underlying filesystem or
134+
/// file access API, or from an administratively imposed resource limitation.
135+
/// Simple disk full, and out of quota, have their own errors.
136+
FileTooLarge,
117137
}
118138

119139
#[cfg(feature = "std")]
@@ -137,6 +157,11 @@ impl From<ErrorKind> for std::io::ErrorKind {
137157
ErrorKind::Interrupted => std::io::ErrorKind::Interrupted,
138158
ErrorKind::Unsupported => std::io::ErrorKind::Unsupported,
139159
ErrorKind::OutOfMemory => std::io::ErrorKind::OutOfMemory,
160+
ErrorKind::ReadOnlyFilesystem => std::io::ErrorKind::ReadOnlyFilesystem,
161+
ErrorKind::StorageFull => std::io::ErrorKind::StorageFull,
162+
ErrorKind::NotSeekable => std::io::ErrorKind::NotSeekable,
163+
ErrorKind::QuotaExceeded => std::io::ErrorKind::QuotaExceeded,
164+
ErrorKind::FileTooLarge => std::io::ErrorKind::FileTooLarge,
140165
_ => std::io::ErrorKind::Other,
141166
}
142167
}
@@ -163,6 +188,11 @@ impl From<std::io::ErrorKind> for ErrorKind {
163188
std::io::ErrorKind::Interrupted => ErrorKind::Interrupted,
164189
std::io::ErrorKind::Unsupported => ErrorKind::Unsupported,
165190
std::io::ErrorKind::OutOfMemory => ErrorKind::OutOfMemory,
191+
std::io::ErrorKind::ReadOnlyFilesystem => ErrorKind::ReadOnlyFilesystem,
192+
std::io::ErrorKind::StorageFull => ErrorKind::StorageFull,
193+
std::io::ErrorKind::NotSeekable => ErrorKind::NotSeekable,
194+
std::io::ErrorKind::QuotaExceeded => ErrorKind::QuotaExceeded,
195+
std::io::ErrorKind::FileTooLarge => ErrorKind::FileTooLarge,
166196
_ => ErrorKind::Other,
167197
}
168198
}

0 commit comments

Comments
 (0)