Make the Unknown field optional

Several other uses that currently rely on num-traits for conversion have
no Unknown representation. Thus, the converter now outputs only known
variants or an error and the exposing function then can put the error
value into an Unknown variant instead.
This commit is contained in:
Andreas Molzer committed 2019-11-10 18:02:08 +01:00
1 parent ffdeb62b9f
commit f80f4a06d5
2 files changed
+30 -13

No files matched your search

+1 -1
View File
@@ -454,7 +454,7 @@ impl<R: Read + Seek> Decoder<R> {
// Value 4 bytes either a pointer the value itself
fn read_entry(&mut self) -> TiffResult<Option<(ifd::Tag, ifd::Entry)>> {
let tag = ifd::Tag::from_u16(self.read_short()?);
let type_: ifd::Type = match FromPrimitive::from_u16(self.read_short()?) {
let type_ = match ifd::Type::from_u16(self.read_short()?) {
Some(t) => t,
None => {
// Unknown type. Skip this entry according to spec.