Open quilan1 opened 2 years ago
I've added my thoughts on idiomatic code style above but in terms of functionality, I do believe this is already decently covers a few cases. We clearly signal when a result is not standard compliant (except for implementation bugs) but have an interface to return the main decoding result as far as possible nevertheless.
Finding a non-license encumbered test is always a hassle. However, as a guidance you can add a subfolder tests/recover
structured similar to reftest
. I'm not sure which properties we even want to test for these images, though. Maybe start with asserting that a recoverable error is returned without checking the exact contents?
Thought I might start the conversation around a manner in which one could recover partially rendered image pixel data from a corrupt or partially invalid jpeg file.
Still to do / discuss:
Just wanted to throw out a minimally invasive rough draft, perhaps to start some thinking about things.
======================
Currently, this library is rather rigid, with respect to the specification. If an error occurs while decoding the stream, the error is returned and recovery of the partially decoded image is impossible.
However, there are some occasions where it may be possible, to return the potentially incomplete image data. In this case, the
try_recover
function may be used on the result of thedecode
function. If the data supports recovery, the incomplete pixels are returned, but if not, it simply returns the error.Added the
TryRecover
trait, theError::Recoverable
condition and implemented a simple example usage -- if an image does not have an EOI segment, it yields a recoverable error.Usage of the functionality is straightforward: