diff --git a/src/error.rs b/src/error.rs index 5576c74..1996794 100644 --- a/src/error.rs +++ b/src/error.rs @@ -28,7 +28,7 @@ use std::error; use std::fmt; use std::io; -/// An error type returned when parsing Exif data. +/// An error returned when parsing of Exif data fails. #[derive(Debug)] #[non_exhaustive] pub enum Error { diff --git a/src/lib.rs b/src/lib.rs index 819cc61..bc3df6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,17 +61,14 @@ //! # let exif = Reader::new().read_from_container( //! # &mut std::io::BufReader::new(&file)).unwrap(); //! # macro_rules! eprintln { ($($tt:tt)*) => (panic!($($tt)*)) } -//! // Orientation is stored as a SHORT. +//! // Orientation is stored as a SHORT. You could match `orientation.value` +//! // against `Value::Short`, but the standard recommends that readers +//! // should accept BYTE, SHORT, or LONG values for any unsigned integer +//! // field. `Value::get_uint` is provided for that purpose. //! match exif.get_field(Tag::Orientation, In::PRIMARY) { //! Some(orientation) => -//! // You could match `orientation.value` against `Value::Short`, -//! // but the standard recommends that BYTE, SHORT, or LONG should -//! // be accepted. `Value::get_uint` is provided for that purpose. //! match orientation.value.get_uint(0) { -//! Some(v @ 1..=8) => { -//! println!("Orientation {}", v); -//! # assert_eq!(v, 1); -//! }, +//! Some(v @ 1..=8) => println!("Orientation {}", v), //! _ => eprintln!("Orientation value is broken"), //! }, //! None => eprintln!("Orientation tag is missing"), @@ -80,11 +77,8 @@ //! match exif.get_field(Tag::XResolution, In::PRIMARY) { //! Some(xres) => //! match xres.value { -//! Value::Rational(ref v) if !v.is_empty() => { -//! println!("XResolution {}", v[0]); -//! # assert_eq!(v[0].num, 72); -//! # assert_eq!(v[0].denom, 1); -//! }, +//! Value::Rational(ref v) if !v.is_empty() => +//! println!("XResolution {}", v[0]), //! _ => eprintln!("XResolution value is broken"), //! }, //! None => eprintln!("XResolution tag is missing"), diff --git a/src/reader.rs b/src/reader.rs index 0a9bd1f..f4807b5 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -63,7 +63,7 @@ pub struct Reader { } impl Reader { - /// Construct a new `Reader`. + /// Constructs a new `Reader`. pub fn new() -> Self { Self {} } diff --git a/src/tag.rs b/src/tag.rs index 769ff12..68f43f9 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -31,7 +31,7 @@ use crate::value; use crate::value::Value; use crate::util::atou16; -/// A tag of a TIFF field. +/// A tag of a TIFF/Exif field. /// /// Some well-known tags are provided as associated constants of /// this type. The constant names follow the Exif specification @@ -64,8 +64,8 @@ impl Tag { /// # Examples /// ``` /// use exif::{Context, Tag}; - /// assert_eq!(Tag::DateTime.context(), Context::Tiff); - /// assert_eq!(Tag::ExposureTime.context(), Context::Exif); + /// assert_eq!(Tag::XResolution.context(), Context::Tiff); + /// assert_eq!(Tag::DateTimeOriginal.context(), Context::Exif); /// ``` #[inline] pub fn context(self) -> Context { @@ -77,7 +77,8 @@ impl Tag { /// # Examples /// ``` /// use exif::Tag; - /// assert_eq!(Tag::DateTime.number(), 0x132); + /// assert_eq!(Tag::XResolution.number(), 0x11a); + /// assert_eq!(Tag::DateTimeOriginal.number(), 0x9003); /// ``` #[inline] pub fn number(self) -> u16 { @@ -91,7 +92,7 @@ impl Tag { } /// Returns the default value of the tag. `None` is returned if - /// it is not defined in the standard or it depends on the context. + /// it is not defined in the standard or it depends on another tag. #[inline] pub fn default_value(&self) -> Option { get_tag_info(*self).and_then(|ti| (&ti.default).into()) @@ -781,6 +782,7 @@ fn d_planarcfg(w: &mut dyn fmt::Write, value: &Value) -> fmt::Result { } // ResolutionUnit (TIFF 0x128) +// FocalPlaneResolutionUnit (Exif 0xa210) fn d_resunit(w: &mut dyn fmt::Write, value: &Value) -> fmt::Result { let s = match value.get_uint(0) { Some(1) => "no absolute unit", diff --git a/src/tiff.rs b/src/tiff.rs index 69ab000..9b15bc6 100644 --- a/src/tiff.rs +++ b/src/tiff.rs @@ -98,7 +98,7 @@ impl IfdEntry { } } -/// A TIFF field. +/// A TIFF/Exif field. #[derive(Debug, Clone)] pub struct Field { /// The tag of this field. @@ -109,7 +109,7 @@ pub struct Field { pub value: Value, } -/// The IFD number. +/// An IFD number. /// /// The IFDs are indexed from 0. The 0th IFD is for the primary image /// and the 1st one is for the thumbnail. Two associated constants, diff --git a/src/value.rs b/src/value.rs index 9908a72..1700719 100644 --- a/src/value.rs +++ b/src/value.rs @@ -29,7 +29,7 @@ use std::fmt::Write as _; use crate::endian::Endian; -/// Types and values of TIFF fields (for Exif attributes). +/// A type and values of a TIFF/Exif field. #[derive(Clone)] pub enum Value { /// Vector of 8-bit unsigned integers.