1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//
// Copyright (c) 2020 KAMADA Ken'ichi.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//

//! Documentation

// Rust 1.54 stabilized invoking function-like macros in attributes.
// We will use it after bumping MSRV.
// #![feature(extended_key_value_attributes)],
// #[doc = include_str!("../NEWS")]
// pub mod news {}
macro_rules! doc_module_with_external_source {
    ($( #[$attr:meta] )*
     $name: ident, $doc: expr) => {
        $( #[$attr] )*
        #[doc = ""]
        #[doc = $doc]
        pub mod $name {}
    }
}
doc_module_with_external_source!(
    /// # News
    news, include_str!("../NEWS"));

/// # Upgrade Guide
///
/// ## Upgrade from 0.4.x to 0.5.x
///
/// ### API compatibilities
///
/// * `Reader` has been split into two: `Reader` and `Exif`.
///   `Reader` is now the builder for `Exif`, and `Exif` provides
///   access to `Field`s via `get_field`, `fields`, and other methods.
///   Old code `Reader::new(data)` should be changed to
///   `Reader::new().read_raw(data)` or
///   `Reader::new().read_from_container(data)`.
///
///   The old code using 0.4.x:
///   ```ignore
///   # use exif::Reader;
///   # let file = std::fs::File::open("tests/exif.jpg").unwrap();
///   # let mut bufreader = std::io::BufReader::new(&file);
///   let reader = Reader::new(&mut bufreader).unwrap();
///   for f in reader.fields() { /* do something */ }
///   ```
///   The new code using 0.5.x:
///   ```
///   # use exif::{Exif, Reader};
///   # let file = std::fs::File::open("tests/exif.jpg").unwrap();
///   # let mut bufreader = std::io::BufReader::new(&file);
///   let exif = Reader::new().read_from_container(&mut bufreader).unwrap();
///   for f in exif.fields() { /* do something */ }
///   ```
///
/// ### Other new features
///
/// * Support for parsing Exif in HEIF (HEIC/AVIF) has been added.
///
/// ## Upgrade from 0.3.x to 0.4.x
///
/// ### API compatibilities
///
/// * Use struct `In` instead of `bool` to indicate primary/thumbnail images.
///   - On `Reader::get_field`, the old code using 0.3.x:
///     ```ignore
///     reader.get_field(Tag::DateTime, false)
///     ```
///     The new code using 0.4.x:
///     ```ignore
///     # use exif::{In, Reader, Tag};
///     # let file = std::fs::File::open("tests/exif.tif").unwrap();
///     # let reader = Reader::new(
///     #     &mut std::io::BufReader::new(&file)).unwrap();
///     reader.get_field(Tag::DateTime, In::PRIMARY)
///     # ;
///     ```
///     As an additional feature, access to the 2nd or further IFD,
///     which some TIFF-based RAW formats may have, is also possible
///     with 0.4.x:
///     ```ignore
///     # use exif::{In, Reader, Tag};
///     # let file = std::fs::File::open("tests/exif.tif").unwrap();
///     # let reader = Reader::new(
///     #     &mut std::io::BufReader::new(&file)).unwrap();
///     reader.get_field(Tag::ImageWidth, In(2))
///     # ;
///     ```
///   - On `Field`, the old code using 0.3.x:
///     ```ignore
///     if field.thumbnail {
///         // for the thumbnail image
///     } else {
///         // for the primary image
///     }
///     ```
///     The new code using 0.4.x:
///     ```
///     # use exif::{In, Reader};
///     # let file = std::fs::File::open("tests/exif.tif").unwrap();
///     # let exif = Reader::new().read_from_container(
///     #     &mut std::io::BufReader::new(&file)).unwrap();
///     # let field = exif.fields().next().unwrap();
///     match field.ifd_num {
///         In::PRIMARY => {},   // for the primary image
///         In::THUMBNAIL => {}, // for the thumbnail image
///         _ => {},
///     }
///     ```
/// * `Reader::fields` now returns an iterator instead of a slice.
/// * Enum variants of `Context` and `Error` are no longer exhaustive.
///   You need a wildcard arm (`_`) in a match expression.
/// * The associated value of `Value::Undefined` and `Value::Ascii` has
///   been changed from a slice to a `Vec`.
///
/// ### Other new features
///
/// * `Field::display_value` has been introduced.
///   It is usually handier than `Value::display_as`.
///   ```
///   # let file = std::fs::File::open("tests/exif.tif").unwrap();
///   # let exif = exif::Reader::new().read_from_container(
///   #     &mut std::io::BufReader::new(&file)).unwrap();
///   # let field = exif.fields().next().unwrap();
///   assert_eq!(field.display_value().to_string(),
///              field.value.display_as(field.tag).to_string());
///   ```
/// * Displaying a value with its unit is supported.
///   ```ignore
///   # let file = std::fs::File::open("tests/exif.tif").unwrap();
///   # let reader = exif::Reader::new(
///   #     &mut std::io::BufReader::new(&file)).unwrap();
///   # let field = reader.fields().next().unwrap();
///   // Display the value only.
///   println!("{}", field.display_value());
///   // Display the value with its unit.  If the unit depends on another
///   // field, it is taken from the reader.
///   println!("{}", field.display_value().with_unit(&reader));
///   ```
/// * `Value` and `Field` are self-contained and no longer borrow the raw
///   buffer or `Reader` (thanks to the change of `Value::Undefined`
///   and `Value::Ascii` described above).
pub mod upgrade {}