feat: implement embedded-io and embedded-io-async traits
Allows much better interoperatibility with other embedded rust projects, which by now usually have support for embedded-io traits.
Of course this is feature-gated.
Thanks for the PR! Some initial thoughts:
- Why not implement these on
Filedirectly? AFAIS that’s the only struct implementing thelittlefs2::io::*traits. That would be more ergonomic than having to create wrapper structs. - Then it would also make sense to have a
Seekimplementation. - Maybe we should just use the
embedded-iotraits instead of our own? I’ll run some tests how that would affect binary size, if at all. - Is it really useful to have an
asyncimplementation if it just calls the blocking trait?
- Is it really useful to have an
asyncimplementation if it just calls the blocking trait?
Adding async implementations that are not really async is useless and confusing IMO.
When I call an async function my expectation is that this function will not block.
And it also does not really add anything, because nothing prevents you from calling the sync version from an async function anyway.
This would only be useful if littlefs2 would allow users to provide an AsyncStorage.
async littlefs will not be an option until the upstream C project has some form of support for async operations. That seems unlikely to happen soon.
The most likely way to obtain support for async littlefs would be to re-implement it in native Rust, rather than relying on the upstream C implementation. Since trussed is written with synchronous implementations, this is unlikely to be in scope of this crate for a while.