Add byte expected error and cleanup

This commit is contained in:
ruffson committed 2020-09-25 20:06:52 +02:00
1 parent 63f09b267a
commit 72474b569e
4 files changed
+6 -8

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@ impl Value {
match self {
Byte(val) => Ok(val),
val => Err(TiffError::FormatError(
TiffFormatError::UnsignedIntegerExpected(val),
TiffFormatError::ByteExpected(val),
)),
}
}
@@ -454,7 +454,7 @@ impl Entry {
}
},
(Type::UNDEFINED, n) => self.decode_offset(n, bo, limits, decoder, |decoder| {
Ok(Unsigned(u32::from(decoder.read_byte()?)))
Ok(Byte(u8::from(decoder.read_byte()?)))
}),
_ => Err(TiffError::UnsupportedError(
TiffUnsupportedError::UnsupportedDataType,
-1
View File
@@ -11,7 +11,6 @@ use tags::{CompressionMethod, PhotometricInterpretation, Predictor, SampleFormat
use self::stream::{
ByteOrder, DeflateReader, EndianReader, LZWReader, PackBitsReader, SmartReader, JpegReader
};
use tags::{CompressionMethod, PhotometricInterpretation, Predictor, Tag, Type};
pub mod ifd;
mod stream;
+4
View File
@@ -45,6 +45,7 @@ pub enum TiffFormatError {
InvalidTagValueType(Tag),
RequiredTagNotFound(Tag),
UnknownPredictor(u16),
ByteExpected(Value),
UnsignedIntegerExpected(Value),
SignedIntegerExpected(Value),
InflateError(InflateError),
@@ -69,6 +70,9 @@ impl fmt::Display for TiffFormatError {
UnknownPredictor(ref predictor) => {
write!(fmt, "Unknown predictor “{}” encountered", predictor)
}
ByteExpected(ref val) => {
write!(fmt, "Expected byte, {:?} found.", val)
}
UnsignedIntegerExpected(ref val) => {
write!(fmt, "Expected unsigned integer, {:?} found.", val)
}
-5
View File
@@ -111,11 +111,6 @@ pub enum Tag(u16) unknown("A private or extension tag") {
Threshholding = 263, // TODO add support
XResolution = 282,
YResolution = 283,
TileWidth = 322,
TileLength = 323,
TileOffsets = 324,
TileByteCounts = 325,
SampleFormat = 339,
// JPEG
JPEGTables = 347,
// Advanced tags