Expose ability to read tags to crate users

This commit is contained in:
zroug committed 2018-07-10 17:21:06 +02:00
1 parent 123cc10379
commit e3f89490c6
1 file changed
+7 -7
+7 -7
View File
@@ -15,7 +15,7 @@ use self::stream::{
PackBitsReader PackBitsReader
}; };
mod ifd; pub mod ifd;
mod stream; mod stream;
/// Result of a decoding process /// Result of a decoding process
@@ -344,7 +344,7 @@ impl<R: Read + Seek> Decoder<R> {
/// Tries to retrieve a tag. /// Tries to retrieve a tag.
/// Return `Ok(None)` if the tag is not present. /// Return `Ok(None)` if the tag is not present.
fn find_tag(&mut self, tag: ifd::Tag) -> TiffResult<Option<ifd::Value>> { pub fn find_tag(&mut self, tag: ifd::Tag) -> TiffResult<Option<ifd::Value>> {
let ifd: &Directory = unsafe { let ifd: &Directory = unsafe {
let ifd = self.ifd.as_ref().unwrap(); // Ok to fail let ifd = self.ifd.as_ref().unwrap(); // Ok to fail
// Get a immutable borrow of self // Get a immutable borrow of self
@@ -359,7 +359,7 @@ impl<R: Read + Seek> Decoder<R> {
} }
/// Tries to retrieve a tag and convert it to the desired type. /// Tries to retrieve a tag and convert it to the desired type.
fn find_tag_u32(&mut self, tag: ifd::Tag) -> TiffResult<Option<u32>> { pub fn find_tag_u32(&mut self, tag: ifd::Tag) -> TiffResult<Option<u32>> {
match self.find_tag(tag)? { match self.find_tag(tag)? {
Some(val) => val.into_u32().map(Some), Some(val) => val.into_u32().map(Some),
None => Ok(None) None => Ok(None)
@@ -367,7 +367,7 @@ impl<R: Read + Seek> Decoder<R> {
} }
/// Tries to retrieve a tag and convert it to the desired type. /// Tries to retrieve a tag and convert it to the desired type.
fn find_tag_u32_vec(&mut self, tag: ifd::Tag) -> TiffResult<Option<Vec<u32>>> { pub fn find_tag_u32_vec(&mut self, tag: ifd::Tag) -> TiffResult<Option<Vec<u32>>> {
match self.find_tag(tag)? { match self.find_tag(tag)? {
Some(val) => val.into_u32_vec().map(Some), Some(val) => val.into_u32_vec().map(Some),
None => Ok(None) None => Ok(None)
@@ -376,7 +376,7 @@ impl<R: Read + Seek> Decoder<R> {
/// Tries to retrieve a tag. /// Tries to retrieve a tag.
/// Returns an error if the tag is not present /// Returns an error if the tag is not present
fn get_tag(&mut self, tag: ifd::Tag) -> TiffResult<ifd::Value> { pub fn get_tag(&mut self, tag: ifd::Tag) -> TiffResult<ifd::Value> {
match try!(self.find_tag(tag)) { match try!(self.find_tag(tag)) {
Some(val) => Ok(val), Some(val) => Ok(val),
None => Err(TiffError::FormatError(format!( None => Err(TiffError::FormatError(format!(
@@ -386,12 +386,12 @@ impl<R: Read + Seek> Decoder<R> {
} }
/// Tries to retrieve a tag and convert it to the desired type. /// Tries to retrieve a tag and convert it to the desired type.
fn get_tag_u32(&mut self, tag: ifd::Tag) -> TiffResult<u32> { pub fn get_tag_u32(&mut self, tag: ifd::Tag) -> TiffResult<u32> {
self.get_tag(tag)?.into_u32() self.get_tag(tag)?.into_u32()
} }
/// Tries to retrieve a tag and convert it to the desired type. /// Tries to retrieve a tag and convert it to the desired type.
fn get_tag_u32_vec(&mut self, tag: ifd::Tag) -> TiffResult<Vec<u32>> { pub fn get_tag_u32_vec(&mut self, tag: ifd::Tag) -> TiffResult<Vec<u32>> {
self.get_tag(tag)?.into_u32_vec() self.get_tag(tag)?.into_u32_vec()
} }