image-rs / image-png

PNG decoding and encoding library in pure Rust
https://docs.rs/png
Apache License 2.0
357 stars 140 forks source link

Use chunk type in `CrcMismatch` error #322

Closed MichaelMcDonnell closed 2 years ago

MichaelMcDonnell commented 2 years ago

If there is a CRC mismatch, then it would be nice to know which chunk was corrupted. If, for example, the CRC mismatch is in a text chunk, then it would not be a great loss to the user and the image would most likely still be viewable. If, on the other hand, the CRC mismatch is in the image data chunk, then the image on the screen will be garbled to some degree. The user might in that case want to re-request the image from where they got it from.

Using the chunk type also fixes an unused field warning.