| 1 | //! How to write either a single or a list of layers. |
| 2 | |
| 3 | 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#, Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#}; |
| 4 | use craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::{Headersrust-analyzer cargo exr 1.74.0 meta/Headers#, compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().}; |
| 5 | 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#; |
| 6 | use craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::{Layersrust-analyzer cargo exr 1.74.0 image/Layers#, Layerrust-analyzer cargo exr 1.74.0 image/Layer#}; |
| 7 | 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/::{TileDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#}; |
| 8 | use craterust-analyzer cargo exr 1.74.0 crate/::preluderust-analyzer cargo exr 1.74.0 prelude/::{SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#}; |
| 9 | use craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::writerust-analyzer cargo exr 1.74.0 image/write/::channelsrust-analyzer cargo exr 1.74.0 image/write/channels/::{WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#, ChannelsWriterrust-analyzer cargo exr 1.74.0 image/write/channels/ChannelsWriter#}; |
| 10 | use craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::recursiverust-analyzer cargo exr 1.74.0 image/recursive/::{Recursiverust-analyzer cargo exr 1.74.0 image/recursive/Recursive#, NoneMorerust-analyzer cargo exr 1.74.0 image/recursive/NoneMore#}; |
| 11 | |
| 12 | /// Enables an image containing this list of layers to be written to a file. |
| 13 | pub trait WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf> { |
| 14 | |
| 15 | /// Generate the file meta data for this list of layers |
| 16 | fn infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#infer_headers().(&self, image_attributes: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers#; |
| 17 | |
| 18 | /// The type of temporary writer |
| 19 | type Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer#: LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter#; |
| 20 | |
| 21 | /// Create a temporary writer for this list of layers |
| 22 | fn create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#create_writer().(&'slf self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Self::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer#; |
| 23 | } |
| 24 | |
| 25 | /// A temporary writer for a list of channels |
| 26 | pub trait LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter#: Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync# { |
| 27 | |
| 28 | /// Deliver a block of pixels from a single layer to be stored in the file |
| 29 | fn extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter#extract_uncompressed_block().(&self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>; |
| 30 | } |
| 31 | |
| 32 | /// A temporary writer for an arbitrary list of layers |
| 33 | #[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:, 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:)] |
| 34 | pub struct AllLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#<ChannelsWriter> { |
| 35 | layersrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#layers.: SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#<[LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#<ChannelsWriter>; 2]> |
| 36 | } |
| 37 | |
| 38 | /// A temporary writer for a single layer |
| 39 | #[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:, 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:)] |
| 40 | pub struct LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#<ChannelsWriter> { |
| 41 | channelsrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#channels.: ChannelsWriter, // impl ChannelsWriter |
| 42 | } |
| 43 | |
| 44 | // impl for smallvec |
| 45 | impl<'slf, Channels: 'slf> WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf> for Layersrust-analyzer cargo exr 1.74.0 image/Layers#<Channels> where Channels: WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#<'slf> { |
| 46 | fn infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`SmallVec<[Layer<Channels>; 2]>`][`WritableLayers<'slf>`]infer_headers().(&self, image_attributes: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers# { |
| 47 | slice_infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/slice_infer_headers().(self.as_slicerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]as_slice().(), image_attributes) |
| 48 | } |
| 49 | |
| 50 | type Writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`SmallVec<[Layer<Channels>; 2]>`][`WritableLayers<'slf>`]Writer# = AllLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#<Channels::Writerrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#Writer#>; |
| 51 | fn create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`SmallVec<[Layer<Channels>; 2]>`][`WritableLayers<'slf>`]create_writer().(&'slf self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Selfrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`SmallVec<[Layer<Channels>; 2]>`][`WritableLayers<'slf>`]::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer# { |
| 52 | slice_create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/slice_create_writer().(self.as_slicerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]as_slice().(), headers) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | fn slice_infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/slice_infer_headers().<'slf, Channels:'slf + WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#<'slf>>( |
| 57 | slice: &[Layerrust-analyzer cargo exr 1.74.0 image/Layer#<Channels>], image_attributes: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes# |
| 58 | ) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers# |
| 59 | { |
| 60 | slice.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().(|layer| layer.infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]infer_headers().(image_attributes).removerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]remove().(0)).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() // TODO no array-vs-first |
| 61 | } |
| 62 | |
| 63 | fn slice_create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/slice_create_writer().<'slf, Channels:'slf + WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#<'slf>>( |
| 64 | slice: &'slf [Layerrust-analyzer cargo exr 1.74.0 image/Layer#<Channels>], headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#] |
| 65 | ) -> AllLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#<Channels::Writerrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#Writer#> |
| 66 | { |
| 67 | AllLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter# { |
| 68 | layersrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#layers.: slice.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(headers.chunks_exactrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_exact().(1)) // TODO no array-vs-first |
| 69 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(layer, header)| layer.create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]create_writer().(header)) |
| 70 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | |
| 75 | impl<'slf, Channels: WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#<'slf>> WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf> for Layerrust-analyzer cargo exr 1.74.0 image/Layer#<Channels> { |
| 76 | fn infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]infer_headers().(&self, image_attributes: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers# { |
| 77 | let blocks = match self.encodingrust-analyzer cargo exr 1.74.0 image/Layer#encoding..blocksrust-analyzer cargo exr 1.74.0 image/Encoding#blocks. { |
| 78 | craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::Blocksrust-analyzer cargo exr 1.74.0 image/Blocks#::ScanLinesrust-analyzer cargo exr 1.74.0 image/Blocks#ScanLines# => craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::ScanLinesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#ScanLines#, |
| 79 | craterust-analyzer cargo exr 1.74.0 crate/::imagerust-analyzer cargo exr 1.74.0 image/::Blocksrust-analyzer cargo exr 1.74.0 image/Blocks#::Tilesrust-analyzer cargo exr 1.74.0 image/Blocks#Tiles#(tile_size) => { |
| 80 | let (level_mode, rounding_mode) = self.channel_datarust-analyzer cargo exr 1.74.0 image/Layer#channel_data..infer_level_modesrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#infer_level_modes().(); |
| 81 | craterust-analyzer cargo exr 1.74.0 crate/::metarust-analyzer cargo exr 1.74.0 meta/::BlockDescriptionrust-analyzer cargo exr 1.74.0 meta/BlockDescription#::Tilesrust-analyzer cargo exr 1.74.0 meta/BlockDescription#Tiles#(TileDescriptionrust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription# { level_moderust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#level_mode., rounding_moderust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#rounding_mode., tile_sizerust-analyzer cargo exr 1.74.0 meta/attribute/TileDescription#tile_size., }) |
| 82 | }, |
| 83 | }; |
| 84 | |
| 85 | let chunk_count = compute_chunk_countrust-analyzer cargo exr 1.74.0 meta/compute_chunk_count().( |
| 86 | self.encodingrust-analyzer cargo exr 1.74.0 image/Layer#encoding..compressionrust-analyzer cargo exr 1.74.0 image/Encoding#compression., self.sizerust-analyzer cargo exr 1.74.0 image/Layer#size., blocks |
| 87 | ); |
| 88 | |
| 89 | let header = Headerrust-analyzer cargo exr 1.74.0 meta/header/Header# { |
| 90 | channelsrust-analyzer cargo exr 1.74.0 meta/header/Header#channels.: self.channel_datarust-analyzer cargo exr 1.74.0 image/Layer#channel_data..infer_channel_listrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#infer_channel_list().(), |
| 91 | compressionrust-analyzer cargo exr 1.74.0 meta/header/Header#compression.: self.encodingrust-analyzer cargo exr 1.74.0 image/Layer#encoding..compressionrust-analyzer cargo exr 1.74.0 image/Encoding#compression., |
| 92 | |
| 93 | blocksrust-analyzer cargo exr 1.74.0 meta/header/Header#blocks., |
| 94 | chunk_countrust-analyzer cargo exr 1.74.0 meta/header/Header#chunk_count., |
| 95 | |
| 96 | line_orderrust-analyzer cargo exr 1.74.0 meta/header/Header#line_order.: self.encodingrust-analyzer cargo exr 1.74.0 image/Layer#encoding..line_orderrust-analyzer cargo exr 1.74.0 image/Encoding#line_order., |
| 97 | layer_sizerust-analyzer cargo exr 1.74.0 meta/header/Header#layer_size.: self.sizerust-analyzer cargo exr 1.74.0 image/Layer#size., |
| 98 | shared_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#shared_attributes.: image_attributes.clonerust-analyzer cargo exr 1.74.0 meta/header/impl#[ImageAttributes][Clone]clone().(), |
| 99 | own_attributesrust-analyzer cargo exr 1.74.0 meta/header/Header#own_attributes.: self.attributesrust-analyzer cargo exr 1.74.0 image/Layer#attributes..clonerust-analyzer cargo exr 1.74.0 meta/header/impl#[LayerAttributes][Clone]clone().(), |
| 100 | |
| 101 | |
| 102 | deeprust-analyzer cargo exr 1.74.0 meta/header/Header#deep.: false, // TODO deep data |
| 103 | deep_data_versionrust-analyzer cargo exr 1.74.0 meta/header/Header#deep_data_version.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 104 | max_samples_per_pixelrust-analyzer cargo exr 1.74.0 meta/header/Header#max_samples_per_pixel.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 105 | }; |
| 106 | |
| 107 | smallvecrust-analyzer cargo smallvec 1.15.1 smallvec!![ header ]// TODO no array-vs-first |
| 108 | } |
| 109 | |
| 110 | type Writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]Writer# = LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#</*'l,*/ Channels::Writerrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#Writer#>; |
| 111 | fn create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]create_writer().(&'slf self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Selfrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer# { |
| 112 | let channels = self.channel_datarust-analyzer cargo exr 1.74.0 image/Layer#channel_data. |
| 113 | .create_writerrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#create_writer().(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().("inferred header error")); // TODO no array-vs-first |
| 114 | |
| 115 | LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter# { channelsrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#channels. } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | impl<C> LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter# for AllLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#<C> where C: ChannelsWriterrust-analyzer cargo exr 1.74.0 image/write/channels/ChannelsWriter# { |
| 120 | fn extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`AllLayersWriter<C>`][LayersWriter]extract_uncompressed_block().(&self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 121 | self.layersrust-analyzer cargo exr 1.74.0 image/write/layers/AllLayersWriter#layers.[rust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][`Index<I>`]index().block.layerrust-analyzer cargo exr 1.74.0 block/BlockIndex#layer.]rust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`][`Index<I>`]index()..extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`LayerWriter<C>`][LayersWriter]extract_uncompressed_block().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::from_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_ref().(&headers[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().block.layerrust-analyzer cargo exr 1.74.0 block/BlockIndex#layer.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().), block) // TODO no array-vs-first |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | impl<C> LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter# for LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#<C> where C: ChannelsWriterrust-analyzer cargo exr 1.74.0 image/write/channels/ChannelsWriter# { |
| 126 | fn extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`LayerWriter<C>`][LayersWriter]extract_uncompressed_block().(&self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 127 | self.channelsrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#channels..extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/channels/ChannelsWriter#extract_uncompressed_block().(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().("invalid inferred header"), block) // TODO no array-vs-first |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | impl<'slf> WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf> for NoneMorerust-analyzer cargo exr 1.74.0 image/recursive/NoneMore# { |
| 136 | fn infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[NoneMore][`WritableLayers<'slf>`]infer_headers().(&self, _: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers# { SmallVecrust-analyzer cargo smallvec 1.15.1 SmallVec#::newrust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]new().() } |
| 137 | |
| 138 | type Writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[NoneMore][`WritableLayers<'slf>`]Writer# = NoneMorerust-analyzer cargo exr 1.74.0 image/recursive/NoneMore#; |
| 139 | fn create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[NoneMore][`WritableLayers<'slf>`]create_writer().(&'slf self, _: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Selfrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[NoneMore][`WritableLayers<'slf>`]::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer# { NoneMorerust-analyzer cargo exr 1.74.0 image/recursive/NoneMore# } |
| 140 | } |
| 141 | |
| 142 | impl<'slf, InnerLayers, Channels> WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf> for Recursiverust-analyzer cargo exr 1.74.0 image/recursive/Recursive#<InnerLayers, Layerrust-analyzer cargo exr 1.74.0 image/Layer#<Channels>> |
| 143 | where InnerLayers: WritableLayersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#<'slf>, Channels: WritableChannelsrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#<'slf> |
| 144 | { |
| 145 | fn infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Recursive<InnerLayers, Layer<Channels>>`][`WritableLayers<'slf>`]infer_headers().(&self, image_attributes: &ImageAttributesrust-analyzer cargo exr 1.74.0 meta/header/ImageAttributes#) -> Headersrust-analyzer cargo exr 1.74.0 meta/Headers# { |
| 146 | let mut headers = self.innerrust-analyzer cargo exr 1.74.0 image/recursive/Recursive#inner..infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#infer_headers().(image_attributes); |
| 147 | headers.pushrust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]push().(self.valuerust-analyzer cargo exr 1.74.0 image/recursive/Recursive#value..infer_headersrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]infer_headers().(image_attributes).removerust-analyzer cargo smallvec 1.15.1 impl#[`SmallVec<A>`]remove().(0)); // TODO no unwrap |
| 148 | headers |
| 149 | } |
| 150 | |
| 151 | type Writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Recursive<InnerLayers, Layer<Channels>>`][`WritableLayers<'slf>`]Writer# = RecursiveLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/RecursiveLayersWriter#<InnerLayers::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer#, Channels::Writerrust-analyzer cargo exr 1.74.0 image/write/channels/WritableChannels#Writer#>; |
| 152 | |
| 153 | fn create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Recursive<InnerLayers, Layer<Channels>>`][`WritableLayers<'slf>`]create_writer().(&'slf self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#]) -> Selfrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Recursive<InnerLayers, Layer<Channels>>`][`WritableLayers<'slf>`]::Writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#Writer# { |
| 154 | let (own_header, inner_headers) = headers.split_lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]split_last().() |
| 155 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("header has not been inferred correctly"); |
| 156 | |
| 157 | let layer_index = inner_headers.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 158 | RecursiveLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/RecursiveLayersWriter# { |
| 159 | innerrust-analyzer cargo exr 1.74.0 image/recursive/Recursive#inner.: self.innerrust-analyzer cargo exr 1.74.0 image/recursive/Recursive#inner..create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/WritableLayers#create_writer().(inner_headers), |
| 160 | valuerust-analyzer cargo exr 1.74.0 image/recursive/Recursive#value.: (layer_index, self.valuerust-analyzer cargo exr 1.74.0 image/recursive/Recursive#value..create_writerrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Layer<Channels>`][`WritableLayers<'slf>`]create_writer().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::from_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_ref().(own_header))) // TODO no slice |
| 161 | } |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | type RecursiveLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/RecursiveLayersWriter#<InnerLayersWriter, ChannelsWriter> = Recursiverust-analyzer cargo exr 1.74.0 image/recursive/Recursive#<InnerLayersWriter, (usize, LayerWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayerWriter#<ChannelsWriter>)>; |
| 166 | |
| 167 | impl LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter# for NoneMorerust-analyzer cargo exr 1.74.0 image/recursive/NoneMore# { |
| 168 | fn extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[NoneMore][LayersWriter]extract_uncompressed_block().(&self, _: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], _: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 169 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("recursive length mismatch bug"); |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | impl<InnerLayersWriter, Channels> LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter# for RecursiveLayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/RecursiveLayersWriter#<InnerLayersWriter, Channels> |
| 174 | where InnerLayersWriter: LayersWriterrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter#, Channels: ChannelsWriterrust-analyzer cargo exr 1.74.0 image/write/channels/ChannelsWriter# |
| 175 | { |
| 176 | fn extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`Recursive<InnerLayersWriter, (usize, LayerWriter<Channels>)>`][LayersWriter]extract_uncompressed_block().(&self, headers: &[Headerrust-analyzer cargo exr 1.74.0 meta/header/Header#], block: BlockIndexrust-analyzer cargo exr 1.74.0 block/BlockIndex#) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> { |
| 177 | let (layer_index, layer) = &self.valuerust-analyzer cargo exr 1.74.0 image/recursive/Recursive#value.; |
| 178 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().layer_index 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().block.layerrust-analyzer cargo exr 1.74.0 block/BlockIndex#layer. { |
| 179 | let header = headers.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().layer_index).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("layer index bug"); |
| 180 | layer.extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/impl#[`LayerWriter<C>`][LayersWriter]extract_uncompressed_block().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::from_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_ref().(header), block) // TODO no slice? |
| 181 | } |
| 182 | else { |
| 183 | self.innerrust-analyzer cargo exr 1.74.0 image/recursive/Recursive#inner..extract_uncompressed_blockrust-analyzer cargo exr 1.74.0 image/write/layers/LayersWriter#extract_uncompressed_block().(headers, block) |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 |