From 5d9190304f32414a22bdb4fdf66b6747adb10ae0 Mon Sep 17 00:00:00 2001 From: KAMADA Ken'ichi Date: Sat, 17 Dec 2016 00:30:46 +0900 Subject: [PATCH] Return the little-endian flag from parse_exif(). --- src/tiff.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tiff.rs b/src/tiff.rs index c40ae24..c297ea0 100644 --- a/src/tiff.rs +++ b/src/tiff.rs @@ -48,14 +48,18 @@ pub struct Field<'a> { } /// Parse the Exif attributes in the TIFF format. -pub fn parse_exif(data: &[u8]) -> Result, Error> { +/// +/// Returns a Vec of Exif fields and a bool. +/// The boolean value is true if the data is little endian. +/// If an error occured, `exif::Error` is returned. +pub fn parse_exif(data: &[u8]) -> Result<(Vec, bool), Error> { // Check the byte order and call the real parser. if data.len() < 8 { return Err(Error::InvalidFormat("Truncated TIFF header")); } match BigEndian::loadu16(data, 0) { - TIFF_BE => parse_exif_sub::(data), - TIFF_LE => parse_exif_sub::(data), + TIFF_BE => parse_exif_sub::(data).map(|v| (v, false)), + TIFF_LE => parse_exif_sub::(data).map(|v| (v, true)), _ => Err(Error::InvalidFormat("Invalid TIFF byte order")), } }