embedded-hal icon indicating copy to clipboard operation
embedded-hal copied to clipboard

Expand embedded_io::ErrorKind to better match std::io::ErrorKind.

Open jacobguenther opened this issue 11 months ago • 2 comments

embedded_io::ErrorKind only has 18 variants while std::io::ErrorKind has 41. I am porting a zip library to no_std and would like to use more of the variants. Some of these variants would also be useful for filesystems on sdcards. These are some of the errors I need to use. NotADirectory, IsADirectory, DirectoryNotEmpty, ReadOnlyFilesystem, StorageFull, NotSeekable, QuotaExceeded, FileTooLarge, CrossesDevices, InvalidFilename, UnexpectedEof,

I don't see why not implementing all of them though?

jacobguenther avatar Feb 10 '25 03:02 jacobguenther

I think only some make sense as kinds:

  • Those make sense: ReadOnlyFilesystem, StorageFull, NotSeekable, QuotaExceeded, FileTooLarge
  • Those apply to operations that are not possible through embedded-io:
    • NotADirectory, IsADirectory, DirectoryNotEmpty (for directory operations or file opening)
    • CrossesDevices (for moving)
    • InvalidFilename (for opening files)
  • UnexpectedEof is already present as part of ReadExactError

chrysn avatar Aug 08 '25 18:08 chrysn

ResourceBusy and InProgress are not bad either for indicating that the read/write head is unavailable.

ResourceBusy to indicate that either:

  • control of the read/write head is owned by someone else
  • or that taking control would corrupt the stream state.

InProgress to indicate that either:

  • a stream is already undergoing an operation
  • or like EINPROGRESS (for socket connections) where the stream state (socket connection) setup is still underway (awaiting connection established).

anonhostpi avatar Sep 17 '25 08:09 anonhostpi