Debian Codegraph @

src/meta/mod.rs

raw symbols SCIP
1
2 //! Describes all meta data possible in an exr file.
3 //! Contains functionality to read and write meta data from bytes.
4 //! Browse the `exr::image` module to get started with the high-level interface.
5
6 pub mod attributerust-analyzer cargo exr 1.74.0 meta/attribute/;
7 pub mod headerrust-analyzer cargo exr 1.74.0 meta/header/;
8
9
10 use craterust-analyzer cargo exr 1.74.0 crate/::iorust-analyzer cargo exr 1.74.0 io/::*;
11 use ::smallvecrust-analyzer cargo smallvec 1.15.1 crate/::SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#;
12 use selfrust-analyzer cargo exr 1.74.0 meta/::attributerust-analyzer cargo exr 1.74.0 meta/attribute/::*;
13 use craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::chunkrust-analyzer cargo exr 1.74.0 block/chunk/::{TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#, CompressedBlockrust-analyzer cargo exr 1.74.0 block/chunk/CompressedBlock#};
14 use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::*;
15 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#;
16 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#};
17 use craterust-analyzer cargo exr 1.74.0 crate/::mathrust-analyzer cargo exr 1.74.0 math/::*;
18 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/::{HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#};
19 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#;
20 use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::headerrust-analyzer cargo exr 1.74.0 meta/header/::{Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#};
21 use craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::{BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#, UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#};
22
23
24 // TODO rename MetaData to ImageInfo?
25
26 /// Contains the complete meta data of an exr image.
27 /// Defines how the image is split up in the file,
28 /// the number and type of images and channels,
29 /// and various other attributes.
30 /// The usage of custom attributes is encouraged.
31 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
32 pub struct MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData# {
33
34 /// Some flags summarizing the features that must be supported to decode the file.
35 pub requirementsrust-analyzer cargo exr 1.74.0 meta/MetaData#requirements.: Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements#,
36
37 /// One header to describe each layer in this file.
38 // TODO rename to layer descriptions?
39 pub headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers.: Headersrust-analyzer cargo exr 1.74.0 meta/Headers#,
40 }
41
42
43 /// List of `Header`s.
44 pub type Headersrust-analyzer cargo exr 1.74.0 meta/Headers# = SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#<[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#; 3]>;
45
46 /// List of `OffsetTable`s.
47 pub type OffsetTablesrust-analyzer cargo exr 1.74.0 meta/OffsetTables# = SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#<[OffsetTablerust-analyzer cargo exr 1.74.0 meta/OffsetTable#; 3]>;
48
49
50 /// The offset table is an ordered list of indices referencing pixel data in the exr file.
51 /// For each pixel tile in the image, an index exists, which points to the byte-location
52 /// of the corresponding pixel data in the file. That index can be used to load specific
53 /// portions of an image without processing all bytes in a file. For each header,
54 /// an offset table exists with its indices ordered by `LineOrder::Increasing`.
55 // If the multipart bit is unset and the chunkCount attribute is not present,
56 // the number of entries in the chunk table is computed using the
57 // dataWindow, tileDesc, and compression attribute.
58 //
59 // If the multipart bit is set, the header must contain a
60 // chunkCount attribute, that contains the length of the offset table.
61 pub type OffsetTablerust-analyzer cargo exr 1.74.0 meta/OffsetTable# = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u64>;
62
63
64 /// A summary of requirements that must be met to read this exr file.
65 /// Used to determine whether this file can be read by a given reader.
66 /// It includes the OpenEXR version number. This library aims to support version `2.0`.
67 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
68 pub struct Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
69
70 /// This library supports reading version 1 and 2, and writing version 2.
71 // TODO write version 1 for simple images
72 pub file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.: u8,
73
74 /// If true, this image has tiled blocks and contains only a single layer.
75 /// If false and not deep and not multilayer, this image is a single layer image with scan line blocks.
76 pub is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.: bool,
77
78 // in c or bad c++ this might have been relevant (omg is he allowed to say that)
79 /// Whether this file has strings with a length greater than 31.
80 /// Strings can never be longer than 255.
81 pub has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.: bool,
82
83 /// This image contains at least one layer with deep data.
84 pub has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data.: bool,
85
86 /// Whether this file contains multiple layers.
87 pub has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.: bool,
88 }
89
90
91 /// Locates a rectangular section of pixels in an image.
92 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
93 pub struct TileIndicesrust-analyzer cargo exr 1.74.0 meta/TileIndices# {
94
95 /// Index of the tile.
96 pub locationrust-analyzer cargo exr 1.74.0 meta/TileIndices#location.: TileCoordinatesrust-analyzer cargo exr 1.74.0 block/chunk/TileCoordinates#,
97
98 /// Pixel size of the tile.
99 pub sizerust-analyzer cargo exr 1.74.0 meta/TileIndices#size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>,
100 }
101
102 /// How the image pixels are split up into separate blocks.
103 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
104 pub enum BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription# {
105
106 /// The image is divided into scan line blocks.
107 /// The number of scan lines in a block depends on the compression method.
108 ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#,
109
110 /// The image is divided into tile blocks.
111 /// Also specifies the size of each tile in the image
112 /// and whether this image contains multiple resolution levels.
113 Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles#(TileDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#)
114 }
115
116
117 /*impl TileIndices {
118 pub fn cmp(&self, other: &Self) -> Ordering {
119 match self.location.level_index.1.cmp(&other.location.level_index.1) {
120 Ordering::Equal => {
121 match self.location.level_index.0.cmp(&other.location.level_index.0) {
122 Ordering::Equal => {
123 match self.location.tile_index.1.cmp(&other.location.tile_index.1) {
124 Ordering::Equal => {
125 self.location.tile_index.0.cmp(&other.location.tile_index.0)
126 },
127
128 other => other,
129 }
130 },
131
132 other => other
133 }
134 },
135
136 other => other
137 }
138 }
139 }*/
140
141 impl BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription# {
142
143 /// Whether this image is tiled. If false, this image is divided into scan line blocks.
144 pub fn has_tilesrust-analyzer cargo exr 1.74.0 meta/impl#[BlockDescription]has_tiles().(&self) -> bool {
145 match self {
146 BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles# { .. } => true,
147 _ => false
148 }
149 }
150 }
151
152
153
154
155
156 /// The first four bytes of each exr file.
157 /// Used to abort reading non-exr files.
158 pub mod magic_numberrust-analyzer cargo exr 1.74.0 meta/magic_number/ {
159 use superrust-analyzer cargo exr 1.74.0 meta/::*;
160
161 /// The first four bytes of each exr file.
162 pub const BYTESrust-analyzer cargo exr 1.74.0 meta/magic_number/BYTES.: [u8; 4] = [0x76, 0x2f, 0x31, 0x01];
163
164 /// Without validation, write this instance to the byte stream.
165 pub fn writerust-analyzer cargo exr 1.74.0 meta/magic_number/write().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<()> {
166 u8::write_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[u8][Data]write_slice_ne().(write, &selfrust-analyzer cargo exr 1.74.0 meta/magic_number/::BYTESrust-analyzer cargo exr 1.74.0 meta/magic_number/BYTES.)
167 }
168
169 /// Consumes four bytes from the reader and returns whether the file may be an exr file.
170 // TODO check if exr before allocating BufRead
171 pub fn is_exrrust-analyzer cargo exr 1.74.0 meta/magic_number/is_exr().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<bool> {
172 let mut magic_num = [0; 4];
173 u8::read_slice_nerust-analyzer cargo exr 1.74.0 io/impl#[u8][Data]read_slice_ne().(read, &mut magic_num)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
174 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(magic_num rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`[T; N]`][`PartialEq<[U; N]>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`[T; N]`][`PartialEq<[U; N]>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/equality/impl#[`[T; N]`][`PartialEq<[U; N]>`]eq().selfrust-analyzer cargo exr 1.74.0 meta/magic_number/::BYTESrust-analyzer cargo exr 1.74.0 meta/magic_number/BYTES.)
175 }
176
177 /// Validate this image. If it is an exr file, return `Ok(())`.
178 pub fn validate_exrrust-analyzer cargo exr 1.74.0 meta/magic_number/validate_exr().(read: &mut impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
179 if selfrust-analyzer cargo exr 1.74.0 meta/magic_number/::is_exrrust-analyzer cargo exr 1.74.0 meta/magic_number/is_exr().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). {
180 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
181
182 } else {
183 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("file identifier missing"))
184 }
185 }
186 }
187
188 /// A `0_u8` at the end of a sequence.
189 pub mod sequence_endrust-analyzer cargo exr 1.74.0 meta/sequence_end/ {
190 use superrust-analyzer cargo exr 1.74.0 meta/::*;
191
192 /// Number of bytes this would consume in an exr file.
193 pub fn byte_sizerust-analyzer cargo exr 1.74.0 meta/sequence_end/byte_size().() -> usize {
194 1
195 }
196
197 /// Without validation, write this instance to the byte stream.
198 pub fn writerust-analyzer cargo exr 1.74.0 meta/sequence_end/write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
199 0_u8.write_lerust-analyzer cargo exr 1.74.0 io/impl#[u8][Data]write_le().(write)
200 }
201
202 /// Peeks the next byte. If it is zero, consumes the byte and returns true.
203 pub fn has_comerust-analyzer cargo exr 1.74.0 meta/sequence_end/has_come().(read: &mut PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<bool> {
204 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(read.skip_if_eqrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]skip_if_eq().(0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
205 }
206 }
207
208 fn missing_attributerust-analyzer cargo exr 1.74.0 meta/missing_attribute().(name: &str) -> Errorrust-analyzer cargo exr 1.74.0 error/Error# {
209 Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("missing or invalid {} attribute", name))
210 }
211
212
213 /// Compute the number of tiles required to contain all values.
214 pub fn compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(full_res: usize, tile_size: usize) -> usize {
215 // round up, because if the image is not evenly divisible by the tiles,
216 // we add another tile at the end (which is only partially used)
217 RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#::Uprust-analyzer cargo exr 1.74.0 math/RoundingMode#Up#.dividerust-analyzer cargo exr 1.74.0 math/impl#[RoundingMode]divide().(full_res, tile_size)
218 }
219
220 /// Compute the start position and size of a block inside a dimension.
221 #[inline]
222 pub fn calculate_block_position_and_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_position_and_size().(total_size: usize, block_size: usize, block_index: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<(usize, usize)> {
223 let block_position = block_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().block_index;
224
225 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((
226 block_position,
227 calculate_block_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_size().(total_size, block_size, block_position)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
228 ))
229 }
230
231 /// Calculate the size of a single block. If this is the last block,
232 /// this only returns the required size, which is always smaller than the default block size.
233 // TODO use this method everywhere instead of convoluted formulas
234 #[inline]
235 pub fn calculate_block_sizerust-analyzer cargo exr 1.74.0 meta/calculate_block_size().(total_size: usize, block_size: usize, block_position: usize) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<usize> {
236 if block_position rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().total_size {
237 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("block index"))
238 }
239
240 if block_position rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().block_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().<=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]le().total_size {
241 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(block_size)
242 }
243 else {
244 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(total_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().block_position)
245 }
246 }
247
248
249 /// Calculate number of mip levels in a given resolution.
250 // TODO this should be cached? log2 may be very expensive
251 pub fn compute_level_countrust-analyzer cargo exr 1.74.0 meta/compute_level_count().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, full_res: usize) -> usize {
252 usize::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[usize][`TryFrom<u32>`]try_from().(round.log2rust-analyzer cargo exr 1.74.0 math/impl#[RoundingMode]log2().(u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u32][`TryFrom<usize>`]try_from().(full_res).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1
253 }
254
255 /// Calculate the size of a single mip level by index.
256 // TODO this should be cached? log2 may be very expensive
257 pub fn compute_level_sizerust-analyzer cargo exr 1.74.0 meta/compute_level_size().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, full_res: usize, level_index: usize) -> usize {
258 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(level_index <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). 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().::<usize>() *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). 8, "largest level size exceeds maximum integer value");
259 round.dividerust-analyzer cargo exr 1.74.0 math/impl#[RoundingMode]divide().(full_res, 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<Self>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<Self>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shl<Self>`]shl().level_index).maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(1)
260 }
261
262 /// Iterates over all rip map level resolutions of a given size, including the indices of each level.
263 /// The order of iteration conforms to `LineOrder::Increasing`.
264 // TODO cache these?
265 // TODO compute these directly instead of summing up an iterator?
266 pub fn rip_map_levelsrust-analyzer cargo exr 1.74.0 meta/rip_map_levels().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, max_resolution: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> 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#=(Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>)> {
267 rip_map_indicesrust-analyzer cargo exr 1.74.0 meta/rip_map_indices().(round, max_resolution).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |level_indices|{
268 // TODO progressively divide instead??
269 let width = compute_level_sizerust-analyzer cargo exr 1.74.0 meta/compute_level_size().(round, max_resolution.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().(), level_indices.xrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]x().());
270 let height = compute_level_sizerust-analyzer cargo exr 1.74.0 meta/compute_level_size().(round, max_resolution.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(), level_indices.yrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]y().());
271 (level_indices, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(width, height))
272 })
273 }
274
275 /// Iterates over all mip map level resolutions of a given size, including the indices of each level.
276 /// The order of iteration conforms to `LineOrder::Increasing`.
277 // TODO cache all these level values when computing table offset size??
278 // TODO compute these directly instead of summing up an iterator?
279 pub fn mip_map_levelsrust-analyzer cargo exr 1.74.0 meta/mip_map_levels().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, max_resolution: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> 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#=(usize, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>)> {
280 mip_map_indicesrust-analyzer cargo exr 1.74.0 meta/mip_map_indices().(round, max_resolution)
281 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |level_index|{
282 // TODO progressively divide instead??
283 let width = compute_level_sizerust-analyzer cargo exr 1.74.0 meta/compute_level_size().(round, max_resolution.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().(), level_index);
284 let height = compute_level_sizerust-analyzer cargo exr 1.74.0 meta/compute_level_size().(round, max_resolution.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(), level_index);
285 (level_index, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(width, height))
286 })
287 }
288
289 /// Iterates over all rip map level indices of a given size.
290 /// The order of iteration conforms to `LineOrder::Increasing`.
291 pub fn rip_map_indicesrust-analyzer cargo exr 1.74.0 meta/rip_map_indices().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, max_resolution: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> 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#=Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>> {
292 let (width, height) = (
293 compute_level_countrust-analyzer cargo exr 1.74.0 meta/compute_level_count().(round, max_resolution.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().()),
294 compute_level_countrust-analyzer cargo exr 1.74.0 meta/compute_level_count().(round, max_resolution.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().())
295 );
296
297 (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#height).flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(move |y_level|{
298 (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#width).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |x_level|{
299 Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(x_level, y_level)
300 })
301 })
302 }
303
304 /// Iterates over all mip map level indices of a given size.
305 /// The order of iteration conforms to `LineOrder::Increasing`.
306 pub fn mip_map_indicesrust-analyzer cargo exr 1.74.0 meta/mip_map_indices().(round: RoundingModerust-analyzer cargo exr 1.74.0 math/RoundingMode#, max_resolution: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>) -> 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#=usize> {
307 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#compute_level_countrust-analyzer cargo exr 1.74.0 meta/compute_level_count().(round, max_resolution.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().().maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(max_resolution.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().()))
308 }
309
310 /// Compute the number of chunks that an image is divided into. May be an expensive operation.
311 // If not multilayer and chunkCount not present,
312 // the number of entries in the chunk table is computed
313 // using the dataWindow and tileDesc attributes and the compression format
314 pub fn compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().(compression: Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#, data_size: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#<usize>, blocks: BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#) -> usize {
315
316 if let BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles#(tiles) = blocks {
317 let round = tiles.rounding_moderust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#rounding_mode.;
318 let Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(tile_width, tile_height) = tiles.tile_sizerust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#tile_size.;
319
320 // TODO cache all these level values??
321 use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::attributerust-analyzer cargo exr 1.74.0 meta/attribute/::LevelModerust-analyzer cargo exr 1.74.0 meta/attribute/LevelMode#::*;
322 match tiles.level_moderust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#level_mode. {
323 Singularrust-analyzer cargo exr 1.74.0 meta/attribute/LevelMode#Singular# => {
324 let tiles_x = compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(data_size.widthrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]width().(), tile_width);
325 let tiles_y = compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(data_size.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(), tile_height);
326 tiles_x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().tiles_y
327 }
328
329 MipMaprust-analyzer cargo exr 1.74.0 meta/attribute/LevelMode#MipMap# => {
330 mip_map_levelsrust-analyzer cargo exr 1.74.0 meta/mip_map_levels().(round, data_size).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(level_width, level_height))| {
331 compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(level_width, tile_width) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(level_height, tile_height)
332 }).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().()
333 },
334
335 RipMaprust-analyzer cargo exr 1.74.0 meta/attribute/LevelMode#RipMap# => {
336 rip_map_levelsrust-analyzer cargo exr 1.74.0 meta/rip_map_levels().(round, data_size).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(_, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(level_width, level_height))| {
337 compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(level_width, tile_width) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(level_height, tile_height)
338 }).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().()
339 }
340 }
341 }
342
343 // scan line blocks never have mip maps
344 else {
345 compute_block_countrust-analyzer cargo exr 1.74.0 meta/compute_block_count().(data_size.heightrust-analyzer cargo exr 1.74.0 math/impl#[`Vec2<T>`]height().(), compression.scan_lines_per_blockrust-analyzer cargo exr 1.74.0 compression/impl#[Compression]scan_lines_per_block().())
346 }
347 }
348
349
350
351 impl MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData# {
352
353 /// Read the exr meta data from a file.
354 /// Use `read_from_unbuffered` instead if you do not have a file.
355 /// Does not validate the meta data.
356 #[must_use]
357 pub fn read_from_filerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_file().(path: impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>, pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]> {
358 Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]::read_from_unbufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_unbuffered().(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., pedantic)
359 }
360
361 /// Buffer the reader and then read the exr meta data from it.
362 /// Use `read_from_buffered` if your reader is an in-memory reader.
363 /// Use `read_from_file` if you have a file path.
364 /// Does not validate the meta data.
365 #[must_use]
366 pub fn read_from_unbufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_unbuffered().(unbuffered: impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]> {
367 Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]::read_from_bufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_buffered().(BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(unbuffered), pedantic)
368 }
369
370 /// Read the exr meta data from a reader.
371 /// Use `read_from_file` if you have a file path.
372 /// Use `read_from_unbuffered` if this is not an in-memory reader.
373 /// Does not validate the meta data.
374 #[must_use]
375 pub fn read_from_bufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_buffered().(buffered: impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]> {
376 let mut read = PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#::newrust-analyzer cargo exr 1.74.0 io/impl#[`PeekRead<T>`]new().(buffered);
377 MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_unvalidated_from_buffered_peekablerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_unvalidated_from_buffered_peekable().(&mut read, pedantic)
378 }
379
380 /// Does __not validate__ the meta data completely.
381 #[must_use]
382 pub(craterust-analyzer cargo exr 1.74.0 crate/) fn read_unvalidated_from_buffered_peekablerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_unvalidated_from_buffered_peekable().(read: &mut PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>, pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]> {
383 magic_numberrust-analyzer cargo exr 1.74.0 meta/magic_number/::validate_exrrust-analyzer cargo exr 1.74.0 meta/magic_number/validate_exr().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
384
385 let requirements = Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements#::readrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]read().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
386
387 // do this check now in order to fast-fail for newer versions and features than version 2
388 requirements.validaterust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]validate().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
389
390 let headers = Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#::read_allrust-analyzer cargo exr 1.74.0 meta/header/impl#[Header]read_all().(read, &requirements, pedantic)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
391
392 // TODO check if supporting requirements 2 always implies supporting requirements 1
393 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData# { requirementsrust-analyzer cargo exr 1.74.0 meta/MetaData#requirements., headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers. })
394 }
395
396 /// Validates the meta data.
397 #[must_use]
398 pub(craterust-analyzer cargo exr 1.74.0 crate/) fn read_validated_from_buffered_peekablerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_validated_from_buffered_peekable().(
399 read: &mut PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>, pedantic: bool
400 ) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]> {
401 let meta_data = Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]::read_unvalidated_from_buffered_peekablerust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_unvalidated_from_buffered_peekable().(read, !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().pedantic)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
402 MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(meta_data.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers..as_slicerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]as_slice().(), pedantic)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
403 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(meta_data)
404 }
405
406 /// Validates the meta data and writes it to the stream.
407 /// If pedantic, throws errors for files that may produce errors in other exr readers.
408 /// Returns the automatically detected minimum requirement flags.
409 pub(craterust-analyzer cargo exr 1.74.0 crate/) fn write_validating_to_bufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]write_validating_to_buffered().(write: &mut impl Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements#> {
410 // pedantic validation to not allow slightly invalid files
411 // that still could be read correctly in theory
412 let minimal_requirements = Selfrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]::validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(headers, pedantic)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
413
414 magic_numberrust-analyzer cargo exr 1.74.0 meta/magic_number/::writerust-analyzer cargo exr 1.74.0 meta/magic_number/write().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
415 minimal_requirements.writerust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]write().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
416 Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#::write_allrust-analyzer cargo exr 1.74.0 meta/header/impl#[Header]write_all().(headers, write, minimal_requirements.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
417 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(minimal_requirements)
418 }
419
420 /// Read one offset table from the reader for each header.
421 pub fn read_offset_tablesrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_offset_tables().(read: &mut PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>, headers: &Headersrust-analyzer cargo exr 1.74.0 meta/Headers#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<OffsetTablesrust-analyzer cargo exr 1.74.0 meta/OffsetTables#> {
422 headers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
423 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|header| u64::read_vec_lerust-analyzer cargo exr 1.74.0 io/Data#read_vec_le().(read, header.chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count., u16::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]MAX. as usize, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "offset table size"))
424 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
425 }
426
427 /// Skip the offset tables by advancing the reader by the required byte count.
428 // TODO use seek for large (probably all) tables!
429 pub fn skip_offset_tablesrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]skip_offset_tables().(read: &mut PeekReadrust-analyzer cargo exr 1.74.0 io/PeekRead#<impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>, headers: &Headersrust-analyzer cargo exr 1.74.0 meta/Headers#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<usize> {
430 let chunk_count: usize = headers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|header| header.chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count.).sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().();
431 craterust-analyzer cargo exr 1.74.0 crate/::iorust-analyzer cargo exr 1.74.0 io/::skip_bytesrust-analyzer cargo exr 1.74.0 io/skip_bytes().(read, chunk_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().u64::BYTE_SIZErust-analyzer cargo exr 1.74.0 io/Data#BYTE_SIZE.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; // TODO this should seek for large tables
432 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(chunk_count)
433 }
434
435 /// This iterator tells you the block indices of all blocks that must be in the image.
436 /// The order of the blocks depends on the `LineOrder` attribute
437 /// (unspecified line order is treated the same as increasing line order).
438 /// The blocks written to the file must be exactly in this order,
439 /// except for when the `LineOrder` is unspecified.
440 /// The index represents the block index, in increasing line order, within the header.
441 pub fn enumerate_ordered_header_block_indicesrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]enumerate_ordered_header_block_indices().(&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#=(usize, BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#)> {
442 craterust-analyzer cargo exr 1.74.0 crate/::blockrust-analyzer cargo exr 1.74.0 block/::enumerate_ordered_header_block_indicesrust-analyzer cargo exr 1.74.0 block/enumerate_ordered_header_block_indices().(&self.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers.)
443 }
444
445 /// Go through all the block indices in the correct order and call the specified closure for each of these blocks.
446 /// That way, the blocks indices are filled with real block data and returned as an iterator.
447 /// The closure returns the an `UncompressedBlock` for each block index.
448 pub fn collect_ordered_blocksrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]collect_ordered_blocks().<'s>(&'s self, mut get_block: impl 's + FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#)
449 -> impl 's + 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#=(usize, UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#)>
450 {
451 self.enumerate_ordered_header_block_indicesrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]enumerate_ordered_header_block_indices().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |(index_in_header, block_index)|{
452 (index_in_header, get_block(block_index))
453 })
454 }
455
456 /// Go through all the block indices in the correct order and call the specified closure for each of these blocks.
457 /// That way, the blocks indices are filled with real block data and returned as an iterator.
458 /// The closure returns the byte data for each block index.
459 pub fn collect_ordered_block_datarust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]collect_ordered_block_data().<'s>(&'s self, mut get_block_data: impl 's + FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>)
460 -> impl 's + 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#=(usize, UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#)>
461 {
462 self.collect_ordered_blocksrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]collect_ordered_blocks().(move |block_index|
463 UncompressedBlockrust-analyzer cargo exr 1.74.0 block/UncompressedBlock# { indexrust-analyzer cargo exr 1.74.0 block/UncompressedBlock#index.: block_index, datarust-analyzer cargo exr 1.74.0 block/UncompressedBlock#data.: get_block_data(block_index) }
464 )
465 }
466
467 /// Validates this meta data. Returns the minimal possible requirements.
468 pub fn validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], pedantic: bool) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements#> {
469 if headers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
470 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("at least one layer is required"));
471 }
472
473 let deep = false; // TODO deep data
474 let is_multilayer = headers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1;
475 let first_header_has_tiles = headers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().()
476 .map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(false, |header| header.blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks..has_tilesrust-analyzer cargo exr 1.74.0 meta/impl#[BlockDescription]has_tiles().());
477
478 let mut minimal_requirements = Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
479 // according to the spec, version 2 should only be necessary if `is_multilayer || deep`.
480 // but the current open exr library does not support images with version 1, so always use version 2.
481 file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.: 2,
482
483 // start as low as possible, later increasing if required
484 has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.: false,
485
486 is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.: !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_multilayer && first_header_has_tiles,
487 has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.: is_multilayer,
488 has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data.: deep,
489 };
490
491 for header in headers {
492 if header.deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep. { // TODO deep data (and then remove this check)
493 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::unsupportedrust-analyzer cargo exr 1.74.0 error/impl#[Error]unsupported().("deep data not supported yet"));
494 }
495
496 header.validaterust-analyzer cargo exr 1.74.0 meta/header/impl#[Header]validate().(is_multilayer, &mut minimal_requirements.has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names., pedantic)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
497 }
498
499 // TODO validation fn!
500 /*if let Some(max) = max_pixel_bytes {
501 let byte_size: usize = headers.iter()
502 .map(|header| header.total_pixel_bytes())
503 .sum();
504
505 if byte_size > max {
506 return Err(Error::invalid("image larger than specified maximum"));
507 }
508 }*/
509
510 if pedantic { // check for duplicate header names
511 let mut header_names = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::with_capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]with_capacity().(headers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
512 for header in headers {
513 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().header_names.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(&header.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..layer_namerust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_name.) {
514 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
515 "duplicate layer name: `{}`",
516 header.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..layer_namerust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_name..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("header validation bug")
517 )));
518 }
519 }
520 }
521
522 if pedantic {
523 let must_share = headers.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|header| header.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..otherrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#other..iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]iter().())
524 .anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|(_, value)| value.to_chromaticitiesrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[AttributeValue]to_chromaticities().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() || value.to_time_coderust-analyzer cargo exr 1.74.0 meta/attribute/impl#[AttributeValue]to_time_code().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
525
526 if must_share {
527 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("chromaticities and time code attributes must must not exist in own attributes but shared instead"));
528 }
529 }
530
531 if pedantic && headers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 { // check for attributes that should not differ in between headers
532 let first_header = headers.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("header count validation bug");
533 let first_header_attributes = &first_header.shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes.;
534
535 for header in &headers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
536 if &header.shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().first_header_attributes {
537 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("display window, pixel aspect, chromaticities, and time code attributes must be equal for all headers"))
538 }
539 }
540 }
541
542 debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(minimal_requirements.validaterust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]validate().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().(), "inferred requirements are invalid");
543 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(minimal_requirements)
544 }
545 }
546
547
548
549
550 impl Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
551
552 // this is actually used for control flow, as the number of headers may be 1 in a multilayer file
553 /// Is this file declared to contain multiple layers?
554 pub fn is_multilayerrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]is_multilayer().(&self) -> bool {
555 self.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.
556 }
557
558 /// Read the value without validating.
559 pub fn readrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]read().<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>(read: &mut R) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<Selfrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]> {
560 use ::bit_fieldrust-analyzer cargo bit_field 0.10.3 crate/::BitFieldrust-analyzer cargo bit_field 0.10.3 BitField#;
561
562 let version_and_flags = u32::read_lerust-analyzer cargo exr 1.74.0 io/impl#[u32][Data]read_le().(read)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
563
564 // take the 8 least significant bits, they contain the file format version number
565 let version = (version_and_flags rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitAnd<Self>`]bitand().0x000F) as u8;
566
567 // the 24 most significant bits are treated as a set of boolean flags
568 let is_single_tile = version_and_flags.get_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]get_bit().(9);
569 let has_long_names = version_and_flags.get_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]get_bit().(10);
570 let has_deep_data = version_and_flags.get_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]get_bit().(11);
571 let has_multiple_layers = version_and_flags.get_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]get_bit().(12);
572
573 // all remaining bits except 9, 10, 11 and 12 are reserved and should be 0
574 // if a file has any of these bits set to 1, it means this file contains
575 // a feature that we don't support
576 let unknown_flags = version_and_flags rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`Shr<i32>`]shr().13; // all flags excluding the 12 bits we already parsed
577
578 if unknown_flags rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 { // TODO test if this correctly detects unsupported files
579 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::unsupportedrust-analyzer cargo exr 1.74.0 error/impl#[Error]unsupported().("too new file feature flags"));
580 }
581
582 let version = Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
583 file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.: version,
584 is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.: is_single_tile, has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.,
585 has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data., has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.,
586 };
587
588 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(version)
589 }
590
591 /// Without validation, write this instance to the byte stream.
592 pub fn writerust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]write().<W: Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#>(self, write: &mut W) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
593 use ::bit_fieldrust-analyzer cargo bit_field 0.10.3 crate/::BitFieldrust-analyzer cargo bit_field 0.10.3 BitField#;
594
595 // the 8 least significant bits contain the file format version number
596 // and the flags are set to 0
597 let mut version_and_flags = self.file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version. as u32;
598
599 // the 24 most significant bits are treated as a set of boolean flags
600 version_and_flags.set_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]set_bit().(9, self.is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.);
601 version_and_flags.set_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]set_bit().(10, self.has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.);
602 version_and_flags.set_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]set_bit().(11, self.has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data.);
603 version_and_flags.set_bitrust-analyzer cargo bit_field 0.10.3 impl#[u32][BitField]set_bit().(12, self.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.);
604 // all remaining bits except 9, 10, 11 and 12 are reserved and should be 0
605
606 version_and_flags.write_lerust-analyzer cargo exr 1.74.0 io/impl#[u32][Data]write_le().(write)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
607 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
608 }
609
610 /// Validate this instance.
611 pub fn validaterust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]validate().(&self) -> UnitResultrust-analyzer cargo exr 1.74.0 error/UnitResult# {
612 if self.file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().2 {
613
614 match (
615 self.is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled., self.has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data., self.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.,
616 self.file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.
617 ) {
618 // Single-part scan line. One normal scan line image.
619 (false, false, false, 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#2) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
620
621 // Single-part tile. One normal tiled image.
622 (true, false, false, 1..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#2) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
623
624 // Multi-part (new in 2.0).
625 // Multiple normal images (scan line and/or tiled).
626 (false, false, true, 2) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
627
628 // Single-part deep data (new in 2.0).
629 // One deep tile or deep scan line part
630 (false, true, false, 2) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
631
632 // Multi-part deep data (new in 2.0).
633 // Multiple parts (any combination of:
634 // tiles, scan lines, deep tiles and/or deep scan lines).
635 (false, true, true, 2) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
636
637 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("file feature flags"))
638 }
639 }
640 else {
641 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo exr 1.74.0 error/Error#::unsupportedrust-analyzer cargo exr 1.74.0 error/impl#[Error]unsupported().("file versions other than 2.0 are not supported"))
642 }
643 }
644 }
645
646
647 #[cfg(test)]
648 mod testrust-analyzer cargo exr 1.74.0 meta/test/ {
649 use superrust-analyzer cargo exr 1.74.0 meta/::*;
650 use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::headerrust-analyzer cargo exr 1.74.0 meta/header/::{ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#, LayerAttributesrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#};
651
652 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
653 fn round_trip_requirementsrust-analyzer cargo exr 1.74.0 meta/test/round_trip_requirements().() {
654 let requirements = Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
655 file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.: 2,
656 is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.: true,
657 has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.: false,
658 has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data.: true,
659 has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.: false
660 };
661
662 let mut data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
663 requirements.writerust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]write().(&mut data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
664 let read = Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements#::readrust-analyzer cargo exr 1.74.0 meta/impl#[Requirements]read().(&mut data.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
665 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(requirements, read);
666 }
667
668 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
669 fn round_triprust-analyzer cargo exr 1.74.0 meta/test/round_trip().(){
670 let header = Headerrust-analyzer cargo exr 1.74.0 meta/header/Header# {
671 channelsrust-analyzer cargo exr 1.74.0 meta/header/Header#channels.: ChannelListrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelList#::newrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[ChannelList]new().(smallvecrust-analyzer cargo smallvec 1.15.1 smallvec!![
672 ChannelDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription# {
673 namerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#name.: Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::fromrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text][`From<&'s str>`]from().("main"),
674 sample_typerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sample_type.: SampleTyperust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#::U32rust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#U32#,
675 quantize_linearlyrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#quantize_linearly.: false,
676 samplingrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sampling.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1, 1)
677 }
678 ],
679 ),
680 compressionrust-analyzer cargo exr 1.74.0 meta/header/Header#compression.: Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#,
681 line_orderrust-analyzer cargo exr 1.74.0 meta/header/Header#line_order.: LineOrderrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#::Increasingrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#Increasing#,
682 deep_data_versionrust-analyzer cargo exr 1.74.0 meta/header/Header#deep_data_version.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1),
683 chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count.: compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().(Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333), BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#),
684 max_samples_per_pixelrust-analyzer cargo exr 1.74.0 meta/header/Header#max_samples_per_pixel.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4),
685 shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes.: ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes# {
686 pixel_aspectrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#pixel_aspect.: 3.0,
687 .. ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#::newrust-analyzer cargo exr 1.74.0 meta/header/impl#[ImageAttributes]new().(IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds# {
688 positionrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#position.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2,1),
689 sizerust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(11, 9)
690 })
691 },
692
693 blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks.: BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#,
694 deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep.: false,
695 layer_sizerust-analyzer cargo exr 1.74.0 meta/header/Header#layer_size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333),
696 own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes.: LayerAttributesrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes# {
697 layer_namerust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_name.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::fromrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text][`From<&'s str>`]from().("test name lol")),
698 layer_positionrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_position.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(3, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().5),
699 screen_window_centerrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#screen_window_center.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(0.3, 99.0),
700 screen_window_widthrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#screen_window_width.: 0.19,
701 .. Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo exr 1.74.0 meta/header/impl#[LayerAttributes][Default]default().()
702 }
703 };
704
705 let meta = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData# {
706 requirementsrust-analyzer cargo exr 1.74.0 meta/MetaData#requirements.: Requirementsrust-analyzer cargo exr 1.74.0 meta/Requirements# {
707 file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version.: 2,
708 is_single_layer_and_tiledrust-analyzer cargo exr 1.74.0 meta/Requirements#is_single_layer_and_tiled.: false,
709 has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names.: false,
710 has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data.: false,
711 has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers.: false
712 },
713 headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers.: smallvecrust-analyzer cargo smallvec 1.15.1 smallvec!![ header ],
714 };
715
716
717 let mut data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
718 MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::write_validating_to_bufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]write_validating_to_buffered().(&mut data, meta.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers..as_slicerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]as_slice().(), true).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
719 let meta2 = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::read_from_bufferedrust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]read_from_buffered().(data.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), false).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
720 MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(meta2.headersrust-analyzer cargo exr 1.74.0 meta/MetaData#headers..as_slicerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]as_slice().(), true).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
721 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(meta, meta2);
722 }
723
724 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
725 fn infer_low_requirementsrust-analyzer cargo exr 1.74.0 meta/test/infer_low_requirements().() {
726 let header_version_1_short_names = Headerrust-analyzer cargo exr 1.74.0 meta/header/Header# {
727 channelsrust-analyzer cargo exr 1.74.0 meta/header/Header#channels.: ChannelListrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelList#::newrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[ChannelList]new().(smallvecrust-analyzer cargo smallvec 1.15.1 smallvec!![
728 ChannelDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription# {
729 namerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#name.: Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::fromrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text][`From<&'s str>`]from().("main"),
730 sample_typerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sample_type.: SampleTyperust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#::U32rust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#U32#,
731 quantize_linearlyrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#quantize_linearly.: false,
732 samplingrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sampling.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1, 1)
733 }
734 ],
735 ),
736 compressionrust-analyzer cargo exr 1.74.0 meta/header/Header#compression.: Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#,
737 line_orderrust-analyzer cargo exr 1.74.0 meta/header/Header#line_order.: LineOrderrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#::Increasingrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#Increasing#,
738 deep_data_versionrust-analyzer cargo exr 1.74.0 meta/header/Header#deep_data_version.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1),
739 chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count.: compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().(Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333), BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#),
740 max_samples_per_pixelrust-analyzer cargo exr 1.74.0 meta/header/Header#max_samples_per_pixel.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4),
741 shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes.: ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes# {
742 pixel_aspectrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#pixel_aspect.: 3.0,
743 .. ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#::newrust-analyzer cargo exr 1.74.0 meta/header/impl#[ImageAttributes]new().(IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds# {
744 positionrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#position.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2,1),
745 sizerust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(11, 9)
746 })
747 },
748 blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks.: BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#,
749 deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep.: false,
750 layer_sizerust-analyzer cargo exr 1.74.0 meta/header/Header#layer_size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333),
751 own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes.: LayerAttributesrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes# {
752 otherrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#other.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
753 (Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryFrom<U>`]try_from().("x").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), AttributeValuerust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#::F32rust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#F32#(3.0)),
754 (Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryFrom<U>`]try_from().("y").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), AttributeValuerust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#::F32rust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#F32#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0)),
755 ].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
756 .. Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo exr 1.74.0 meta/header/impl#[LayerAttributes][Default]default().()
757 }
758 };
759
760 let low_requirements = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(
761 &[header_version_1_short_names], true
762 ).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
763
764 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names., false);
765 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version., 2); // always have version 2
766 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data., false);
767 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers., false);
768 }
769
770 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
771 fn infer_high_requirementsrust-analyzer cargo exr 1.74.0 meta/test/infer_high_requirements().() {
772 let header_version_2_long_names = Headerrust-analyzer cargo exr 1.74.0 meta/header/Header# {
773 channelsrust-analyzer cargo exr 1.74.0 meta/header/Header#channels.: ChannelListrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelList#::newrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[ChannelList]new().(
774 smallvecrust-analyzer cargo smallvec 1.15.1 smallvec!![
775 ChannelDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription# {
776 namerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#name.: Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::new_or_panicrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text]new_or_panic().("main"),
777 sample_typerust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sample_type.: SampleTyperust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#::U32rust-analyzer cargo exr 1.74.0 meta/attribute/SampleType#U32#,
778 quantize_linearlyrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#quantize_linearly.: false,
779 samplingrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelDescription#sampling.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(1, 1)
780 }
781 ],
782 ),
783 compressionrust-analyzer cargo exr 1.74.0 meta/header/Header#compression.: Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#,
784 line_orderrust-analyzer cargo exr 1.74.0 meta/header/Header#line_order.: LineOrderrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#::Increasingrust-analyzer cargo exr 1.74.0 meta/attribute/LineOrder#Increasing#,
785 deep_data_versionrust-analyzer cargo exr 1.74.0 meta/header/Header#deep_data_version.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1),
786 chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count.: compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().(Compressionrust-analyzer cargo exr 1.74.0 compression/Compression#::Uncompressedrust-analyzer cargo exr 1.74.0 compression/Compression#Uncompressed#, Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333), BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#),
787 max_samples_per_pixelrust-analyzer cargo exr 1.74.0 meta/header/Header#max_samples_per_pixel.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4),
788 shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes.: ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes# {
789 pixel_aspectrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#pixel_aspect.: 3.0,
790 .. ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#::newrust-analyzer cargo exr 1.74.0 meta/header/impl#[ImageAttributes]new().(IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds# {
791 positionrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#position.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2,1),
792 sizerust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(11, 9)
793 })
794 },
795 blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks.: BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#,
796 deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep.: false,
797 layer_sizerust-analyzer cargo exr 1.74.0 meta/header/Header#layer_size.: Vec2rust-analyzer cargo exr 1.74.0 math/Vec2#(2000, 333),
798 own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes.: LayerAttributesrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes# {
799 layer_namerust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_name.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::new_or_panicrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text]new_or_panic().("oasdasoidfj")),
800 otherrust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#other.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
801 (Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::new_or_panicrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text]new_or_panic().("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), AttributeValuerust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#::F32rust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#F32#(3.0)),
802 (Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::new_or_panicrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text]new_or_panic().("y"), AttributeValuerust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#::F32rust-analyzer cargo exr 1.74.0 meta/attribute/AttributeValue#F32#(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][Neg]neg().1.0)),
803 ].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
804 .. Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo exr 1.74.0 meta/header/impl#[LayerAttributes][Default]default().()
805 }
806 };
807
808 let mut layer_2 = header_version_2_long_names.clonerust-analyzer cargo exr 1.74.0 meta/header/impl#[Header][Clone]clone().();
809 layer_2.own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes..layer_namerust-analyzer cargo exr 1.74.0 meta/header/LayerAttributes#layer_name. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Textrust-analyzer cargo exr 1.74.0 meta/attribute/Text#::new_or_panicrust-analyzer cargo exr 1.74.0 meta/attribute/impl#[Text]new_or_panic().("anythingelse"));
810
811 let low_requirements = MetaDatarust-analyzer cargo exr 1.74.0 meta/MetaData#::validaterust-analyzer cargo exr 1.74.0 meta/impl#[MetaData]validate().(
812 &[header_version_2_long_names, layer_2], true
813 ).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
814
815 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_long_namesrust-analyzer cargo exr 1.74.0 meta/Requirements#has_long_names., true);
816 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.file_format_versionrust-analyzer cargo exr 1.74.0 meta/Requirements#file_format_version., 2);
817 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_deep_datarust-analyzer cargo exr 1.74.0 meta/Requirements#has_deep_data., false);
818 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(low_requirements.has_multiple_layersrust-analyzer cargo exr 1.74.0 meta/Requirements#has_multiple_layers., true);
819 }
820 }
821