jpeg-decoder icon indicating copy to clipboard operation
jpeg-decoder copied to clipboard

Make this crate usable in a no_std environment

Open linkmauve opened this issue 2 years ago • 2 comments

#196 removed most uses of std, but as said there std::io and std::error::Error are two remaining uses of std with no no_std replacement. Here is the tracking issue: https://github.com/rust-lang/rust/issues/48331

This issue is about adding an alternative API which wouldn’t use the io::Read trait for reading JPEG data, so that it could be used in embedded environments.

linkmauve avatar Oct 06 '21 13:10 linkmauve

Do you have a sketch of what the alternative API might look like?

fintelia avatar Oct 06 '21 20:10 fintelia

One possibility to solve this, is to create your own std::io::Read alike Trait with a custom error type and implement this for everything implementing std::io::Read if std is available. This way the same API can be used with your no_std and the std Read type.

I've use a similar approach for std::io::Write to add no_std support to the jpeg-encoder crate.

vstroebel avatar Oct 15 '21 09:10 vstroebel