Debian Codegraph @

src/directory.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::NonZeroU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU64#};
3
4 use craterust-analyzer cargo tiff 0.11.3 crate/::{
5 decoderrust-analyzer cargo tiff 0.11.3 decoder/::ifdrust-analyzer cargo tiff 0.11.3 decoder/ifd/::Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#,
6 tagsrust-analyzer cargo tiff 0.11.3 tags/::{IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer#, Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#},
7 };
8
9 /// An Image File Directory (IFD).
10 ///
11 /// A directory is a map of [`Tag`]s to [`Value`](crate::decoder::ifd::Value)s. The values are
12 /// stored anywhere in the file, with the directory containing the offsets and length of the
13 /// associated values for each tag present in the directory.
14 ///
15 /// A directory can be created with with
16 /// [`Decoder::read_directory`](crate::decoder::Decoder::read_directory) or as an empty directory
17 /// to be extended with entries. A directory may be used with
18 /// [`Decoder::read_directory_tags`](crate::decoder::Decoder::read_directory_tags) to read the
19 /// values associated with tags from an underlying file.
20 #[doc(alias = "IFD")]
21 pub struct Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory# {
22 /// There are at most `u16::MAX` entries in any single directory, the count is stored as a
23 /// 2-byte value. The order in the file is implied to be ascending by tag value (the decoder
24 /// does not mind unordered entries).
25 pub(craterust-analyzer cargo tiff 0.11.3 crate/) entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<u16, Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#>,
26 pub(craterust-analyzer cargo tiff 0.11.3 crate/) next_ifdrust-analyzer cargo tiff 0.11.3 directory/Directory#next_ifd.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<NonZeroU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU64#>,
27 }
28
29 impl Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory# {
30 /// Create a directory in an initial state without entries. Note that an empty directory can
31 /// not be encoded in a file, it must contain at least one entry.
32 pub fn emptyrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]empty().() -> Selfrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory] {
33 Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory# {
34 entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V>`]new().(),
35 next_ifdrust-analyzer cargo tiff 0.11.3 directory/Directory#next_ifd.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
36 }
37 }
38
39 /// Retrieve the value associated with a tag.
40 pub fn getrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]get().(&self, tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#> {
41 self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..getrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get().(&tag.to_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]to_u16().())
42 }
43
44 /// Check if the directory contains a specified tag.
45 pub fn containsrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]contains().(&self, tag: Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#) -> bool {
46 self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..contains_keyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]contains_key().(&tag.to_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]to_u16().())
47 }
48
49 /// Iterate over all known and unknown tags in this directory.
50 pub fn iterrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]iter().(&self) -> impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, &Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#)> + '_ {
51 self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries.
52 .iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().()
53 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::from_u16_exhaustiverust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]from_u16_exhaustive().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k), v))
54 }
55
56 /// Insert additional entries into the directory.
57 ///
58 /// Note that a directory can contain at most `u16::MAX` values. There may be one entry that
59 /// does not fit into the directory. This entry is silently ignored (please check [`Self::len`]
60 /// to detect the condition). Providing a tag multiple times or a tag that already exists
61 /// within this directory overwrites the entry.
62 pub fn extendrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend().(&mut self, iter: impl IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#)>) {
63 // Code size conscious extension, avoid monomorphic extensions with the assumption of these
64 // not being performance sensitive in practice. (Maybe we have a polymorphic interface for
65 // the crate usage in the future.
66 self.extend_innerrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend_inner().(iter.into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#into_iter().().by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().())
67 }
68
69 /// Get the number of entries.
70 pub fn lenrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]len().(&self) -> usize {
71 // The keys are `u16`. Since IFDs are required to have at least one entry this would have
72 // been a trivial thing to do in the specification by storing it minus one but alas. In
73 // BigTIFF the count is stored as 8-bit anyways.
74 self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]len().()
75 }
76
77 /// Check if there are any entries in this directory. Note that an empty directory can not be
78 /// encoded in the file, it must contain at least one entry.
79 pub fn is_emptyrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]is_empty().(&self) -> bool {
80 self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]is_empty().()
81 }
82
83 /// Get the pointer to the next IFD, if it was defined.
84 pub fn nextrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]next().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer#> {
85 self.next_ifdrust-analyzer cargo tiff 0.11.3 directory/Directory#next_ifd..maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|n| IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer#(n.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().()))
86 }
87
88 pub fn set_nextrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]set_next().(&mut self, next: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<IfdPointerrust-analyzer cargo tiff 0.11.3 tags/IfdPointer#>) {
89 self.next_ifdrust-analyzer cargo tiff 0.11.3 directory/Directory#next_ifd. = next.and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|n| NonZeroU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroU64#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(n.0rust-analyzer cargo tiff 0.11.3 tags/IfdPointer#0.));
90 }
91
92 fn extend_innerrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend_inner().(&mut self, iter: &mut dyn Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#)>) {
93 for (tag, entry) in iter {
94 // If the tag is already present, it will be overwritten.
95 let map_entry = self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]entry().(tag.to_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]to_u16().());
96
97 match map_entry {
98 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#::Vacantrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#Vacant#(vacant_entry) => {
99 vacant_entry.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`VacantEntry<'a, K, V, A>`]insert().(entry);
100 }
101 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::btree_maprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree_map/::Entryrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#::Occupiedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/Entry#Occupied#(mut occupied_entry) => {
102 occupied_entry.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/entry/impl#[`OccupiedEntry<'a, K, V, A>`]insert().(entry);
103 }
104 }
105 }
106 }
107
108 pub(craterust-analyzer cargo tiff 0.11.3 crate/) fn encoded_lenrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]encoded_len().<K: craterust-analyzer cargo tiff 0.11.3 crate/::encoderrust-analyzer cargo tiff 0.11.3 encoder/::TiffKindrust-analyzer cargo tiff 0.11.3 encoder/TiffKind#>(&self) -> u64 {
109 let (len_count, len_offset);
110
111 match stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<K::OffsetTyperust-analyzer cargo tiff 0.11.3 encoder/TiffKind#OffsetType#>() {
112 offset @ 4 => {
113 // non-BigTiff uses a `u16` here.
114 len_count = 2;
115 len_offset = offset as u64;
116 }
117 offset => {
118 let offset = offset as u64;
119 // assuming BigTIFF
120 len_count = offset;
121 len_offset = offset;
122 }
123 }
124
125 // Each entry is 12 bytes in classic TIFF, 20 bytes in BigTIFF.
126 let entry_bytes = 4 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().len_offset;
127 len_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().entry_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Mul<Self>`]mul().self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]len().() as u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().len_offset
128 }
129 }
130
131 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory# {
132 fn fmtrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
133 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Directory")
134 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().(
135 "entries",
136 &self.entriesrust-analyzer cargo tiff 0.11.3 directory/Directory#entries..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::from_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]from_u16().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k), v)),
137 )
138 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("next_ifd", &self.next_ifdrust-analyzer cargo tiff 0.11.3 directory/Directory#next_ifd.)
139 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
140 }
141 }
142
143 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#<(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#)> for Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory# {
144 fn from_iterrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory][`FromIterator<(Tag, Entry)>`]from_iter().<T: IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#Item# = (Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#, Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#)>>(iter: T) -> Selfrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory][`FromIterator<(Tag, Entry)>`] {
145 let mut dir = Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#::emptyrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]empty().();
146 dir.extendrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend().(iter);
147 dir
148 }
149 }
150
151 #[cfg(test)]
152 mod testsrust-analyzer cargo tiff 0.11.3 directory/tests/ {
153 use superrust-analyzer cargo tiff 0.11.3 directory/::Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#;
154 use craterust-analyzer cargo tiff 0.11.3 crate/::{decoderrust-analyzer cargo tiff 0.11.3 decoder/::ifdrust-analyzer cargo tiff 0.11.3 decoder/ifd/::Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#, tagsrust-analyzer cargo tiff 0.11.3 tags/::Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#};
155
156 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
157 fn directory_multiple_entriesrust-analyzer cargo tiff 0.11.3 directory/tests/directory_multiple_entries().() {
158 let mut dir = Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#::emptyrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]empty().();
159 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dir.lenrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]len().(), 0);
160
161 dir.extendrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend().((0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX.).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| {
162 let tag = Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::Unknownrust-analyzer cargo tiff 0.11.3 tags/Tag#Unknown#(1);
163 let entry = Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#::new_u64rust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]new_u64().(craterust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Typerust-analyzer cargo tiff 0.11.3 tags/Type#::BYTErust-analyzer cargo tiff 0.11.3 tags/Type#BYTE#, i.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), [0; 8]);
164 (tag, entry)
165 }));
166
167 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dir.lenrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]len().(), 1, "Only one tag was ever modified");
168
169 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
170 dir.getrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]get().(Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::Unknownrust-analyzer cargo tiff 0.11.3 tags/Tag#Unknown#(1))
171 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("tag 1 should be present after this chain")
172 .countrust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]count().(),
173 u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
174 );
175 }
176
177 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
178 fn iteration_orderrust-analyzer cargo tiff 0.11.3 directory/tests/iteration_order().() {
179 let mut dir = Directoryrust-analyzer cargo tiff 0.11.3 directory/Directory#::emptyrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]empty().();
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(dir.lenrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]len().(), 0);
181
182 let fake_entry = Entryrust-analyzer cargo tiff 0.11.3 decoder/ifd/Entry#::new_u64rust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry]new_u64().(craterust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::Typerust-analyzer cargo tiff 0.11.3 tags/Type#::BYTErust-analyzer cargo tiff 0.11.3 tags/Type#BYTE#, 0, [0; 8]);
183 dir.extendrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]extend().((0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#32).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| {
184 let tag = Tagrust-analyzer cargo tiff 0.11.3 tags/Tag#::Unknownrust-analyzer cargo tiff 0.11.3 tags/Tag#Unknown#(i);
185 let entry = fake_entry.clonerust-analyzer cargo tiff 0.11.3 decoder/ifd/impl#[Entry][Clone]clone().();
186 (tag, entry)
187 }));
188
189 let iter_order: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u16> = dir.iterrust-analyzer cargo tiff 0.11.3 directory/impl#[Directory]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(tag, _e)| tag.to_u16rust-analyzer cargo tiff 0.11.3 tags/impl#[Tag]to_u16().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
190 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
191 iter_order,
192 (0..32).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(),
193 "Tags must be in ascending order according to the specification"
194 );
195 }
196 }