| 1 |
//! All IO functionality needed for TIFF decoding |
| 2 |
#[cfg(feature = "webp")] |
| 3 |
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/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#; |
| 4 |
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/::{selfrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/, BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#, BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#, Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, Takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Take#}; |
| 5 |
|
| 6 |
pub use craterust-analyzer cargo tiff 0.11.3 crate/::tagsrust-analyzer cargo tiff 0.11.3 tags/::ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#; |
| 7 |
|
| 8 |
/// Reader that is aware of the byte order. |
| 9 |
#[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:)] |
| 10 |
pub struct EndianReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#<R> { |
| 11 |
readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader.: R, |
| 12 |
pub(craterust-analyzer cargo tiff 0.11.3 crate/) byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order.: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#, |
| 13 |
} |
| 14 |
|
| 15 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> EndianReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#<R> { |
| 16 |
pub fn newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]new().(reader: R, byte_order: ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#) -> Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`] { |
| 17 |
Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`] { readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader., byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. } |
| 18 |
} |
| 19 |
|
| 20 |
pub fn innerrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]inner().(&mut self) -> &mut R { |
| 21 |
&mut self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader. |
| 22 |
} |
| 23 |
|
| 24 |
pub fn goto_offsetrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]goto_offset().(&mut self, offset: u64) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> |
| 25 |
where |
| 26 |
R: Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, |
| 27 |
{ |
| 28 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#seek().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(offset))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 29 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 30 |
} |
| 31 |
|
| 32 |
/// Reads an u16 |
| 33 |
#[inline(always)] |
| 34 |
pub fn read_u16rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_u16().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u16, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 35 |
let mut n = [0u8; 2]; |
| 36 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 37 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 38 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => u16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_le_bytes().(n), |
| 39 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => u16::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]from_be_bytes().(n), |
| 40 |
}) |
| 41 |
} |
| 42 |
|
| 43 |
/// Reads an i16 |
| 44 |
#[inline(always)] |
| 45 |
pub fn read_i16rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_i16().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i16, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 46 |
let mut n = [0u8; 2]; |
| 47 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 48 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 49 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => i16::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]from_le_bytes().(n), |
| 50 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => i16::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i16]from_be_bytes().(n), |
| 51 |
}) |
| 52 |
} |
| 53 |
|
| 54 |
/// Reads an u32 |
| 55 |
#[inline(always)] |
| 56 |
pub fn read_u32rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_u32().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u32, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 57 |
let mut n = [0u8; 4]; |
| 58 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 59 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 60 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(n), |
| 61 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(n), |
| 62 |
}) |
| 63 |
} |
| 64 |
|
| 65 |
/// Reads an i32 |
| 66 |
#[inline(always)] |
| 67 |
pub fn read_i32rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_i32().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i32, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 68 |
let mut n = [0u8; 4]; |
| 69 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 70 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 71 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => i32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]from_le_bytes().(n), |
| 72 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => i32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]from_be_bytes().(n), |
| 73 |
}) |
| 74 |
} |
| 75 |
|
| 76 |
/// Reads an u64 |
| 77 |
#[inline(always)] |
| 78 |
pub fn read_u64rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_u64().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<u64, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 79 |
let mut n = [0u8; 8]; |
| 80 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 81 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 82 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => u64::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_le_bytes().(n), |
| 83 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => u64::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_be_bytes().(n), |
| 84 |
}) |
| 85 |
} |
| 86 |
|
| 87 |
/// Reads an i64 |
| 88 |
#[inline(always)] |
| 89 |
pub fn read_i64rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_i64().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<i64, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 90 |
let mut n = [0u8; 8]; |
| 91 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 92 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 93 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => i64::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_le_bytes().(n), |
| 94 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => i64::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i64]from_be_bytes().(n), |
| 95 |
}) |
| 96 |
} |
| 97 |
|
| 98 |
/// Reads an f32 |
| 99 |
#[inline(always)] |
| 100 |
pub fn read_f32rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_f32().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f32, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 101 |
let mut n = [0u8; 4]; |
| 102 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 103 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f32::from_bitsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f32/impl#[f32]from_bits().(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 104 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(n), |
| 105 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => u32::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_be_bytes().(n), |
| 106 |
})) |
| 107 |
} |
| 108 |
|
| 109 |
/// Reads an f64 |
| 110 |
#[inline(always)] |
| 111 |
pub fn read_f64rust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`EndianReader<R>`]read_f64().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<f64, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> { |
| 112 |
let mut n = [0u8; 8]; |
| 113 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut n)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 114 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(f64::from_bitsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core f64/impl#[f64]from_bits().(match self.byte_orderrust-analyzer cargo tiff 0.11.3 decoder/stream/EndianReader#byte_order. { |
| 115 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::LittleEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#LittleEndian# => u64::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_le_bytes().(n), |
| 116 |
ByteOrderrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#::BigEndianrust-analyzer cargo tiff 0.11.3 tags/ByteOrder#BigEndian# => u64::from_be_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]from_be_bytes().(n), |
| 117 |
})) |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
// |
| 122 |
// # READERS |
| 123 |
// |
| 124 |
|
| 125 |
/// Type alias for the deflate Reader |
| 126 |
#[cfg(feature = "deflate")] |
| 127 |
pub type DeflateReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/DeflateReader#<R> = flate2rust-analyzer cargo flate2 1.1.2 crate/::readrust-analyzer cargo flate2 1.1.2 read/::ZlibDecoderrust-analyzer cargo flate2 1.1.2 zlib/read/ZlibDecoder#<R>; |
| 128 |
|
| 129 |
// |
| 130 |
// ## LZW Reader |
| 131 |
// |
| 132 |
|
| 133 |
/// Reader that decompresses LZW streams |
| 134 |
#[cfg(feature = "lzw")] |
| 135 |
pub struct LZWReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> { |
| 136 |
readerrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#reader.: BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#<Takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Take#<R>>, |
| 137 |
decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#decoder.: weezlrust-analyzer cargo weezl 0.1.10 crate/::decoderust-analyzer cargo weezl 0.1.10 decode/::Decoderrust-analyzer cargo weezl 0.1.10 decode/Decoder#, |
| 138 |
} |
| 139 |
|
| 140 |
#[cfg(feature = "lzw")] |
| 141 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> LZWReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#<R> { |
| 142 |
/// Wraps a reader |
| 143 |
pub fn newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`LZWReader<R>`]new().(reader: R, compressed_length: usize) -> LZWReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#<R> { |
| 144 |
Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`LZWReader<R>`] { |
| 145 |
readerrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#reader.: BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::with_capacityrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]with_capacity().( |
| 146 |
(32 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().1024).minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(compressed_length), |
| 147 |
reader.takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(u64::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/ptr_try_from_impls/impl#[u64][`TryFrom<usize>`]try_from().(compressed_length).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()), |
| 148 |
), |
| 149 |
decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#decoder.: weezlrust-analyzer cargo weezl 0.1.10 crate/::decoderust-analyzer cargo weezl 0.1.10 decode/::Decoderrust-analyzer cargo weezl 0.1.10 decode/Decoder#::with_tiff_size_switchrust-analyzer cargo weezl 0.1.10 decode/impl#[Decoder]with_tiff_size_switch().(weezlrust-analyzer cargo weezl 0.1.10 crate/::BitOrderrust-analyzer cargo weezl 0.1.10 BitOrder#::Msbrust-analyzer cargo weezl 0.1.10 BitOrder#Msb#, 8), |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
#[cfg(feature = "lzw")] |
| 155 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for LZWReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#<R> { |
| 156 |
fn readrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`LZWReader<R>`][Read]read().(&mut self, buf: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 157 |
loop { |
| 158 |
let result = self.decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#decoder..decode_bytesrust-analyzer cargo weezl 0.1.10 decode/impl#[Decoder]decode_bytes().(self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#reader..fill_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`][BufRead]fill_buf().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., buf); |
| 159 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/LZWReader#reader..consumerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`][BufRead]consume().(result.consumed_inrust-analyzer cargo weezl 0.1.10 error/BufferResult#consumed_in.); |
| 160 |
|
| 161 |
match result.statusrust-analyzer cargo weezl 0.1.10 error/BufferResult#status. { |
| 162 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(weezlrust-analyzer cargo weezl 0.1.10 crate/::LzwStatusrust-analyzer cargo weezl 0.1.10 error/LzwStatus#::Okrust-analyzer cargo weezl 0.1.10 error/LzwStatus#Ok#) => { |
| 163 |
if result.consumed_outrust-analyzer cargo weezl 0.1.10 error/BufferResult#consumed_out. 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 { |
| 164 |
continue; |
| 165 |
} else { |
| •166 |
return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result.consumed_outrust-analyzer cargo weezl 0.1.10 error/BufferResult#consumed_out.); |
| 167 |
} |
| 168 |
} |
| 169 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(weezlrust-analyzer cargo weezl 0.1.10 crate/::LzwStatusrust-analyzer cargo weezl 0.1.10 error/LzwStatus#::NoProgressrust-analyzer cargo weezl 0.1.10 error/LzwStatus#NoProgress#) => { |
| 170 |
return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().( |
| 171 |
iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::UnexpectedEofrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#UnexpectedEof#, |
| 172 |
"no lzw end code found", |
| 173 |
)); |
| 174 |
} |
| 175 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(weezlrust-analyzer cargo weezl 0.1.10 crate/::LzwStatusrust-analyzer cargo weezl 0.1.10 error/LzwStatus#::Donerust-analyzer cargo weezl 0.1.10 error/LzwStatus#Done#) => { |
| 176 |
return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(result.consumed_outrust-analyzer cargo weezl 0.1.10 error/BufferResult#consumed_out.); |
| 177 |
} |
| 178 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidDatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidData#, err)), |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
// |
| 185 |
// ## PackBits Reader |
| 186 |
// |
| 187 |
|
| 188 |
/// Internal state machine for the PackBitsReader. |
| 189 |
enum PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState# { |
| 190 |
Headerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Header#, |
| 191 |
Literalrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Literal#, |
| 192 |
Repeatrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat# { valuerust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat#value.: u8 }, |
| 193 |
} |
| 194 |
|
| 195 |
/// Reader that unpacks Apple's `PackBits` format |
| 196 |
pub struct PackBitsReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> { |
| 197 |
readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader.: Takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Take#<R>, |
| 198 |
staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state.: PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#, |
| 199 |
countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count.: usize, |
| 200 |
} |
| 201 |
|
| 202 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> PackBitsReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#<R> { |
| 203 |
/// Wraps a reader |
| 204 |
pub fn newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`PackBitsReader<R>`]new().(reader: R, length: u64) -> Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`PackBitsReader<R>`] { |
| 205 |
Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`PackBitsReader<R>`] { |
| 206 |
readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader.: reader.takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(length), |
| 207 |
staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state.: PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Headerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Header#, |
| 208 |
countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count.: 0, |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for PackBitsReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#<R> { |
| 214 |
fn readrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`PackBitsReader<R>`][Read]read().(&mut self, buf: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 215 |
while let PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Headerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Header# = self.staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state. { |
| 216 |
if self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader..limitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Take<T>`]limit().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().0 { |
| 217 |
return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0); |
| 218 |
} |
| 219 |
let mut header: [u8; 1] = [0]; |
| 220 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut header)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 221 |
let h = header[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). as i8; |
| 222 |
if (-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().127..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i8][Neg]neg().1).containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/impl#[`RangeInclusive<Idx>`]contains().(&h) { |
| 223 |
let mut data: [u8; 1] = [0]; |
| 224 |
self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader..read_exactrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_exact().(&mut data)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 225 |
self.staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state. = PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Repeatrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat# { valuerust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat#value.: data[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). }; |
| 226 |
self.countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count. = (1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Sub<Self>`]sub().h as isize) as usize; |
| 227 |
} else if h rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i8][`PartialOrd<Self>`]ge().0 { |
| 228 |
self.staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state. = PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Literalrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Literal#; |
| 229 |
self.countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count. = h as usize 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; |
| 230 |
} else { |
| 231 |
// h = -128 is a no-op. |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
let length = buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(self.countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count.); |
| 236 |
let actual = match self.staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state. { |
| 237 |
PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Literalrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Literal# => self.readerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#reader..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`Take<T>`][Read]read().(&mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#length]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 238 |
PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Repeatrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat# { valuerust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Repeat#value. } => { |
| 239 |
for b in &mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#length]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). { |
| 240 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().b = value; |
| 241 |
} |
| 242 |
|
| 243 |
length |
| 244 |
} |
| 245 |
PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Headerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Header# => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 246 |
}; |
| 247 |
|
| 248 |
self.countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().actual; |
| 249 |
if self.countrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#count. 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 { |
| 250 |
self.staterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#state. = PackBitsReaderStaterust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#::Headerrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReaderState#Header#; |
| 251 |
} |
| 252 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(actual) |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
#[cfg(feature = "fax")] |
| 257 |
pub struct Group4Readerrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> { |
| 258 |
decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#decoder.: fax34rust-analyzer cargo fax 0.2.6 crate/::decoderrust-analyzer cargo fax 0.2.6 decoder/::Group4Decoderrust-analyzer cargo fax 0.2.6 decoder/Group4Decoder#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Bytesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Bytes#<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#<iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Take#<R>>>>, |
| 259 |
line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf.: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>, |
| 260 |
heightrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#height.: u16, |
| 261 |
widthrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#width.: u16, |
| 262 |
yrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#y.: u16, |
| 263 |
} |
| 264 |
|
| 265 |
#[cfg(feature = "fax")] |
| 266 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Group4Readerrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#<R> { |
| 267 |
pub fn newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`Group4Reader<R>`]new().( |
| 268 |
dimensions: (u32, u32), |
| 269 |
reader: R, |
| 270 |
compressed_length: u64, |
| 271 |
) -> craterust-analyzer cargo tiff 0.11.3 crate/::TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`Group4Reader<R>`]> { |
| 272 |
let width = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(dimensions.0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 273 |
let height = u16::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`TryFrom<u32>`]try_from().(dimensions.1)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 274 |
|
| 275 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`Group4Reader<R>`] { |
| 276 |
decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#decoder.: fax34rust-analyzer cargo fax 0.2.6 crate/::decoderrust-analyzer cargo fax 0.2.6 decoder/::Group4Decoderrust-analyzer cargo fax 0.2.6 decoder/Group4Decoder#::newrust-analyzer cargo fax 0.2.6 decoder/impl#[`Group4Decoder<R>`]new().( |
| 277 |
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#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(reader.takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(compressed_length)).bytesrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#bytes().(), |
| 278 |
width, |
| 279 |
)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()., |
| 280 |
line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf.: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(width.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())), |
| 281 |
widthrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#width., |
| 282 |
heightrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#height., |
| 283 |
yrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#y.: 0, |
| 284 |
}) |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
#[cfg(feature = "fax")] |
| 289 |
impl<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for Group4Readerrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#<R> { |
| 290 |
fn readrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`Group4Reader<R>`][Read]read().(&mut self, buf: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 291 |
// Either we have not read any line or we are at the end of a line. |
| 292 |
if self.line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf..positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]position().() as usize 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().self.line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf..get_refrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]get_ref().().lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() |
| 293 |
&& self.yrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().self.heightrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#height. |
| 294 |
{ |
| 295 |
let next = self.decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#decoder..advancerust-analyzer cargo fax 0.2.6 decoder/impl#[`Group4Decoder<R>`]advance().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(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/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]other().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 296 |
|
| 297 |
match next { |
| 298 |
fax34rust-analyzer cargo fax 0.2.6 crate/::decoderrust-analyzer cargo fax 0.2.6 decoder/::DecodeStatusrust-analyzer cargo fax 0.2.6 decoder/DecodeStatus#::Endrust-analyzer cargo fax 0.2.6 decoder/DecodeStatus#End# => (), |
| 299 |
fax34rust-analyzer cargo fax 0.2.6 crate/::decoderrust-analyzer cargo fax 0.2.6 decoder/::DecodeStatusrust-analyzer cargo fax 0.2.6 decoder/DecodeStatus#::Incompleterust-analyzer cargo fax 0.2.6 decoder/DecodeStatus#Incomplete# => { |
| 300 |
self.yrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().1; |
| 301 |
|
| 302 |
// We known `transitions` yields exactly `self.width` items (per doc). |
| 303 |
// FIXME: performance. We do not need an individual pixel iterator, filling |
| 304 |
// memory especially for long runs can be much quicker. The `transitions` are |
| 305 |
// the positions at which each run-length ends, i.e. the prefix sum of run |
| 306 |
// lengths. Runs in fax4 start with white. |
| 307 |
let transitions = fax34rust-analyzer cargo fax 0.2.6 crate/::decoderrust-analyzer cargo fax 0.2.6 decoder/::pelsrust-analyzer cargo fax 0.2.6 decoder/pels().(self.decoderrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#decoder..transitionrust-analyzer cargo fax 0.2.6 decoder/impl#[`Group4Decoder<R>`]transition().(), self.widthrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#width.); |
| 308 |
|
| 309 |
let buffer = self.line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]get_mut().(); |
| 310 |
buffer.resizerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]resize().(usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(self.widthrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#width.).div_ceilrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]div_ceil().(8), 0u8); |
| 311 |
|
| 312 |
let target = &mut buffer[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().; |
| 313 |
|
| 314 |
// Note: it may seem strange to treat black as 0b1 and white as 0b0 despite all |
| 315 |
// our streams by default decoding as-if PhotometricInterpretation::BlackIsMin. |
| 316 |
// This is however consistent with libtiff. It seems that fax4's "White" |
| 317 |
// differs from what libtiff thinks of as "White". For content, a line of data |
| 318 |
// is in runlength encoding of white-black-white-black always starting with |
| 319 |
// white. In libtiff, the loop always does both colors in one go and the |
| 320 |
// structure is: |
| 321 |
// |
| 322 |
// ``` |
| 323 |
// for (; runs < erun; runs += 2) |
| 324 |
// // white run |
| 325 |
// do { *lp++ = 0L; } while (…) |
| 326 |
// // black run |
| 327 |
// do { *lp++ = -1L; } while (…) |
| 328 |
// ``` |
| 329 |
// |
| 330 |
// So indeed the Fax4::White run is implemented by filling with zeros. |
| 331 |
let mut bits = transitions.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| match c { |
| 332 |
fax34rust-analyzer cargo fax 0.2.6 crate/::Colorrust-analyzer cargo fax 0.2.6 Color#::Blackrust-analyzer cargo fax 0.2.6 Color#Black# => true, |
| 333 |
fax34rust-analyzer cargo fax 0.2.6 crate/::Colorrust-analyzer cargo fax 0.2.6 Color#::Whiterust-analyzer cargo fax 0.2.6 Color#White# => false, |
| 334 |
}); |
| 335 |
|
| 336 |
// Assemble bits in MSB as per our library representation for buffer. |
| 337 |
for byte in target { |
| 338 |
let mut val = 0; |
| 339 |
|
| 340 |
for (idx, bit) in bits.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().().takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(8).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 341 |
val rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOrAssign<Self>`]bitor_assign().u8::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u8][`From<bool>`]from().(bit) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<usize>`]shl().(7 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().idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().8); |
| 342 |
} |
| 343 |
|
| 344 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().byte = val; |
| 345 |
} |
| 346 |
|
| 347 |
self.line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf..set_positionrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]set_position().(0); |
| 348 |
} |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
self.line_bufrust-analyzer cargo tiff 0.11.3 decoder/stream/Group4Reader#line_buf..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`][Read]read().(buf) |
| 353 |
} |
| 354 |
} |
| 355 |
|
| 356 |
#[cfg(feature = "webp")] |
| 357 |
pub struct WebPReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader# { |
| 358 |
innerrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader#inner.: Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>, |
| 359 |
} |
| 360 |
|
| 361 |
#[cfg(feature = "webp")] |
| 362 |
impl WebPReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader# { |
| 363 |
pub fn newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[WebPReader]new().<R: Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# + Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#>( |
| 364 |
reader: R, |
| 365 |
compressed_length: u64, |
| 366 |
samples: u16, |
| 367 |
) -> craterust-analyzer cargo tiff 0.11.3 crate/::TiffResultrust-analyzer cargo tiff 0.11.3 error/TiffResult#<Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[WebPReader]> { |
| 368 |
let mut decoder = |
| 369 |
image_webprust-analyzer cargo image-webp 0.2.4 crate/::WebPDecoderrust-analyzer cargo image-webp 0.2.4 decoder/WebPDecoder#::newrust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]new().(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#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(reader.takerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#take().(compressed_length))) |
| 370 |
.map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidDatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidData#, e))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 371 |
|
| 372 |
if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().(samples rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().4 || (samples rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().3 && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().decoder.has_alpharust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]has_alpha().())) { |
| 373 |
return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().( |
| 374 |
iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidDatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidData#, |
| 375 |
"bad sample count for WebP compressed data", |
| 376 |
) |
| 377 |
.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()); |
| 378 |
} |
| 379 |
|
| 380 |
let total_bytes = |
| 381 |
samples as usize 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().decoder.dimensionsrust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]dimensions().().0 as usize 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().decoder.dimensionsrust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]dimensions().().1 as usize; |
| 382 |
let mut data = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; total_bytes]; |
| 383 |
|
| 384 |
decoder |
| 385 |
.read_imagerust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]read_image().(&mut data) |
| 386 |
.map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::InvalidDatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#InvalidData#, e))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 387 |
|
| 388 |
// Add a fully opaque alpha channel if needed |
| 389 |
if samples rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]eq().4 && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().decoder.has_alpharust-analyzer cargo image-webp 0.2.4 decoder/impl#[`WebPDecoder<R>`]has_alpha().() { |
| 390 |
for i in (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(total_bytes rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().4)).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 391 |
data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i 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().4 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().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = 255; |
| 392 |
data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i 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().4 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().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i 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().3 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().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 393 |
data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i 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().4 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]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i 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().3 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]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 394 |
data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().i 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().4]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = data[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().i 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().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().; |
| 395 |
} |
| 396 |
} |
| 397 |
|
| 398 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[WebPReader] { |
| 399 |
innerrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader#inner.: Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(data), |
| 400 |
}) |
| 401 |
} |
| 402 |
} |
| 403 |
|
| 404 |
#[cfg(feature = "webp")] |
| 405 |
impl Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read# for WebPReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader# { |
| 406 |
fn readrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[WebPReader][Read]read().(&mut self, buf: &mut [u8]) -> iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize> { |
| 407 |
self.innerrust-analyzer cargo tiff 0.11.3 decoder/stream/WebPReader#inner..readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`][Read]read().(buf) |
| 408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
#[cfg(test)] |
| 412 |
mod testrust-analyzer cargo tiff 0.11.3 decoder/stream/test/ { |
| 413 |
use superrust-analyzer cargo tiff 0.11.3 decoder/stream/::*; |
| 414 |
|
| 415 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 416 |
fn test_packbitsrust-analyzer cargo tiff 0.11.3 decoder/stream/test/test_packbits().() { |
| 417 |
let encoded = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 418 |
0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, |
| 419 |
0xAA, |
| 420 |
]; |
| 421 |
let encoded_len = encoded.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(); |
| 422 |
|
| 423 |
let buff = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Cursorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/Cursor#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/cursor/impl#[`Cursor<T>`]new().(encoded); |
| 424 |
let mut decoder = PackBitsReaderrust-analyzer cargo tiff 0.11.3 decoder/stream/PackBitsReader#::newrust-analyzer cargo tiff 0.11.3 decoder/stream/impl#[`PackBitsReader<R>`]new().(buff, encoded_len as u64); |
| 425 |
|
| 426 |
let mut decoded = 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().(); |
| 427 |
decoder.read_to_endrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_end().(&mut decoded).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 428 |
|
| 429 |
let expected = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 430 |
0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22, |
| 431 |
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
| 432 |
]; |
| 433 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(decoded, expected); |
| 434 |
} |
| 435 |
} |