Add byte expected error and cleanup
This commit is contained in:
1 parent
63f09b267a
commit
72474b569e
4 files changed
+6
-8
No files matched your search
+2
-2
@@ -39,7 +39,7 @@ impl Value {
|
|||||||
match self {
|
match self {
|
||||||
Byte(val) => Ok(val),
|
Byte(val) => Ok(val),
|
||||||
val => Err(TiffError::FormatError(
|
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| {
|
(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(
|
_ => Err(TiffError::UnsupportedError(
|
||||||
TiffUnsupportedError::UnsupportedDataType,
|
TiffUnsupportedError::UnsupportedDataType,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use tags::{CompressionMethod, PhotometricInterpretation, Predictor, SampleFormat
|
|||||||
use self::stream::{
|
use self::stream::{
|
||||||
ByteOrder, DeflateReader, EndianReader, LZWReader, PackBitsReader, SmartReader, JpegReader
|
ByteOrder, DeflateReader, EndianReader, LZWReader, PackBitsReader, SmartReader, JpegReader
|
||||||
};
|
};
|
||||||
use tags::{CompressionMethod, PhotometricInterpretation, Predictor, Tag, Type};
|
|
||||||
|
|
||||||
pub mod ifd;
|
pub mod ifd;
|
||||||
mod stream;
|
mod stream;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ pub enum TiffFormatError {
|
|||||||
InvalidTagValueType(Tag),
|
InvalidTagValueType(Tag),
|
||||||
RequiredTagNotFound(Tag),
|
RequiredTagNotFound(Tag),
|
||||||
UnknownPredictor(u16),
|
UnknownPredictor(u16),
|
||||||
|
ByteExpected(Value),
|
||||||
UnsignedIntegerExpected(Value),
|
UnsignedIntegerExpected(Value),
|
||||||
SignedIntegerExpected(Value),
|
SignedIntegerExpected(Value),
|
||||||
InflateError(InflateError),
|
InflateError(InflateError),
|
||||||
@@ -69,6 +70,9 @@ impl fmt::Display for TiffFormatError {
|
|||||||
UnknownPredictor(ref predictor) => {
|
UnknownPredictor(ref predictor) => {
|
||||||
write!(fmt, "Unknown predictor “{}” encountered", predictor)
|
write!(fmt, "Unknown predictor “{}” encountered", predictor)
|
||||||
}
|
}
|
||||||
|
ByteExpected(ref val) => {
|
||||||
|
write!(fmt, "Expected byte, {:?} found.", val)
|
||||||
|
}
|
||||||
UnsignedIntegerExpected(ref val) => {
|
UnsignedIntegerExpected(ref val) => {
|
||||||
write!(fmt, "Expected unsigned integer, {:?} found.", val)
|
write!(fmt, "Expected unsigned integer, {:?} found.", val)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,11 +111,6 @@ pub enum Tag(u16) unknown("A private or extension tag") {
|
|||||||
Threshholding = 263, // TODO add support
|
Threshholding = 263, // TODO add support
|
||||||
XResolution = 282,
|
XResolution = 282,
|
||||||
YResolution = 283,
|
YResolution = 283,
|
||||||
TileWidth = 322,
|
|
||||||
TileLength = 323,
|
|
||||||
TileOffsets = 324,
|
|
||||||
TileByteCounts = 325,
|
|
||||||
SampleFormat = 339,
|
|
||||||
// JPEG
|
// JPEG
|
||||||
JPEGTables = 347,
|
JPEGTables = 347,
|
||||||
// Advanced tags
|
// Advanced tags
|
||||||
|
|||||||
Reference in new issue
Block a user