littlefs2 icon indicating copy to clipboard operation
littlefs2 copied to clipboard

feat: implement embedded-io and embedded-io-async traits

Open elrafoon opened this issue 1 year ago • 3 comments

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.

elrafoon avatar May 06 '24 22:05 elrafoon

Thanks for the PR! Some initial thoughts:

  • Why not implement these on File directly? AFAIS that’s the only struct implementing the littlefs2::io::* traits. That would be more ergonomic than having to create wrapper structs.
  • Then it would also make sense to have a Seek implementation.
  • Maybe we should just use the embedded-io traits 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 async implementation if it just calls the blocking trait?

robin-nitrokey avatar May 07 '24 09:05 robin-nitrokey

  • Is it really useful to have an async implementation 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.

Sympatron avatar May 07 '24 12:05 Sympatron

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.

sosthene-nitrokey avatar Jun 20 '24 13:06 sosthene-nitrokey