Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no_std support for ReadCache #652

Closed
samcday opened this issue Mar 24, 2024 · 3 comments · Fixed by #653
Closed

no_std support for ReadCache #652

samcday opened this issue Mar 24, 2024 · 3 comments · Fixed by #653

Comments

@samcday
Copy link

samcday commented Mar 24, 2024

Hello! I'm using this wonderful crate in a no_std environment. In my particular case, I'm parsing UKI (PEs) files on an ESP (vfat) partition using the fatfs crate.

fatfs mainline branch works in no_std by simply defining their own variants of std::io::Read/Seek traits: https://github.com/rafalh/rust-fatfs/blob/master/src/io.rs ... It's worth noting that the current latest published release depends on the now-defunct core_io crate.

As it happens, I was able to get this working satisfactorily by simply duplicating the entirety of ReadCache + ReadCacheRange, and updating the Read+Seek trait references from std::io to fatfs. The trait signatures are otherwise identical, so everything "just worked" without me needing to wrap my head around how I might implement such a thing myself.

Which got me to thinking ... could the object crate do something similar? That is, export object::io::Read + object::io::Seek traits with some ergonomics to easily coerce std::io variants (not sure how to do that off the top of my head, my Rust-fu is weak).

@samcday
Copy link
Author

samcday commented Mar 24, 2024

Oh it's also worth noting that in no_std environment I had to explicitly bring in the memchr crate, since core::slice::memchr is unstable. I suppose object could also do that when std feature is absent.

@philipc
Copy link
Contributor

philipc commented Mar 25, 2024

Does #653 meet your needs?

I suppose object could also do that when std feature is absent.

It already does. However, it also needs the hashbrown crate, and I don't want that as a dependency all the time, so I added to no_std feature to enable this.

@samcday
Copy link
Author

samcday commented Mar 25, 2024

This is wonderful. I've just tested with your branch and confirm it works exactly as I'd hoped. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants