Coverage Report

Created: 2025-07-18 06:49

/rust/registry/src/index.crates.io-6f17d22bba15001f/tiff-0.10.0/src/decoder/stream.rs
Line
Count
Source (jump to first uncovered line)
1
//! All IO functionality needed for TIFF decoding
2
3
use std::io::{self, BufRead, BufReader, Read, Seek, Take};
4
5
/// Byte order of the TIFF file.
6
#[derive(Clone, Copy, Debug)]
7
pub enum ByteOrder {
8
    /// little endian byte order
9
    LittleEndian,
10
    /// big endian byte order
11
    BigEndian,
12
}
13
14
/// Reader that is aware of the byte order.
15
#[derive(Debug)]
16
pub struct EndianReader<R> {
17
    reader: R,
18
    pub(crate) byte_order: ByteOrder,
19
}
20
21
impl<R: Read + Seek> EndianReader<R> {
22
55.2k
    pub fn new(reader: R, byte_order: ByteOrder) -> Self {
23
55.2k
        Self { reader, byte_order }
24
55.2k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::new
Line
Count
Source
22
49.7k
    pub fn new(reader: R, byte_order: ByteOrder) -> Self {
23
49.7k
        Self { reader, byte_order }
24
49.7k
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
22
2.73k
    pub fn new(reader: R, byte_order: ByteOrder) -> Self {
23
2.73k
        Self { reader, byte_order }
24
2.73k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
22
2.81k
    pub fn new(reader: R, byte_order: ByteOrder) -> Self {
23
2.81k
        Self { reader, byte_order }
24
2.81k
    }
25
26
2.23M
    pub fn inner(&mut self) -> &mut R {
27
2.23M
        &mut self.reader
28
2.23M
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::inner
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Line
Count
Source
26
1.47M
    pub fn inner(&mut self) -> &mut R {
27
1.47M
        &mut self.reader
28
1.47M
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::inner
Line
Count
Source
26
760k
    pub fn inner(&mut self) -> &mut R {
27
760k
        &mut self.reader
28
760k
    }
29
30
30.0k
    pub fn goto_offset(&mut self, offset: u64) -> io::Result<()> {
31
30.0k
        self.reader.seek(io::SeekFrom::Start(offset))?;
32
30.0k
        Ok(())
33
30.0k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::goto_offset
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Line
Count
Source
30
20.1k
    pub fn goto_offset(&mut self, offset: u64) -> io::Result<()> {
31
20.1k
        self.reader.seek(io::SeekFrom::Start(offset))?;
32
20.1k
        Ok(())
33
20.1k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::goto_offset
Line
Count
Source
30
9.92k
    pub fn goto_offset(&mut self, offset: u64) -> io::Result<()> {
31
9.92k
        self.reader.seek(io::SeekFrom::Start(offset))?;
32
9.92k
        Ok(())
33
9.92k
    }
34
35
    /// Reads an u16
36
    #[inline(always)]
37
2.95M
    pub fn read_u16(&mut self) -> Result<u16, io::Error> {
38
2.95M
        let mut n = [0u8; 2];
39
2.95M
        self.reader.read_exact(&mut n)?;
40
2.95M
        Ok(match self.byte_order {
41
2.34M
            ByteOrder::LittleEndian => u16::from_le_bytes(n),
42
613k
            ByteOrder::BigEndian => u16::from_be_bytes(n),
43
        })
44
2.95M
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_u16
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Line
Count
Source
37
1.41M
    pub fn read_u16(&mut self) -> Result<u16, io::Error> {
38
1.41M
        let mut n = [0u8; 2];
39
1.41M
        self.reader.read_exact(&mut n)?;
40
1.41M
        Ok(match self.byte_order {
41
1.04M
            ByteOrder::LittleEndian => u16::from_le_bytes(n),
42
368k
            ByteOrder::BigEndian => u16::from_be_bytes(n),
43
        })
44
1.41M
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Line
Count
Source
37
17.5k
    pub fn read_u16(&mut self) -> Result<u16, io::Error> {
38
17.5k
        let mut n = [0u8; 2];
39
17.5k
        self.reader.read_exact(&mut n)?;
40
17.5k
        Ok(match self.byte_order {
41
17.3k
            ByteOrder::LittleEndian => u16::from_le_bytes(n),
42
162
            ByteOrder::BigEndian => u16::from_be_bytes(n),
43
        })
44
17.5k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u16
Line
Count
Source
37
1.50M
    pub fn read_u16(&mut self) -> Result<u16, io::Error> {
38
1.50M
        let mut n = [0u8; 2];
39
1.50M
        self.reader.read_exact(&mut n)?;
40
1.50M
        Ok(match self.byte_order {
41
1.26M
            ByteOrder::LittleEndian => u16::from_le_bytes(n),
42
244k
            ByteOrder::BigEndian => u16::from_be_bytes(n),
43
        })
44
1.50M
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u16
Line
Count
Source
37
19.8k
    pub fn read_u16(&mut self) -> Result<u16, io::Error> {
38
19.8k
        let mut n = [0u8; 2];
39
19.8k
        self.reader.read_exact(&mut n)?;
40
19.8k
        Ok(match self.byte_order {
41
19.4k
            ByteOrder::LittleEndian => u16::from_le_bytes(n),
42
368
            ByteOrder::BigEndian => u16::from_be_bytes(n),
43
        })
44
19.8k
    }
45
46
    /// Reads an i8
47
    #[inline(always)]
48
92.7k
    pub fn read_i8(&mut self) -> Result<i8, io::Error> {
49
92.7k
        let mut n = [0u8; 1];
50
92.7k
        self.reader.read_exact(&mut n)?;
51
92.7k
        Ok(match self.byte_order {
52
92.7k
            ByteOrder::LittleEndian => i8::from_le_bytes(n),
53
0
            ByteOrder::BigEndian => i8::from_be_bytes(n),
54
        })
55
92.7k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_i8
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Line
Count
Source
48
1
    pub fn read_i8(&mut self) -> Result<i8, io::Error> {
49
1
        let mut n = [0u8; 1];
50
1
        self.reader.read_exact(&mut n)?;
51
0
        Ok(match self.byte_order {
52
0
            ByteOrder::LittleEndian => i8::from_le_bytes(n),
53
0
            ByteOrder::BigEndian => i8::from_be_bytes(n),
54
        })
55
1
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i8
Line
Count
Source
48
92.7k
    pub fn read_i8(&mut self) -> Result<i8, io::Error> {
49
92.7k
        let mut n = [0u8; 1];
50
92.7k
        self.reader.read_exact(&mut n)?;
51
92.7k
        Ok(match self.byte_order {
52
92.7k
            ByteOrder::LittleEndian => i8::from_le_bytes(n),
53
0
            ByteOrder::BigEndian => i8::from_be_bytes(n),
54
        })
55
92.7k
    }
56
57
    /// Reads an i16
58
    #[inline(always)]
59
122k
    pub fn read_i16(&mut self) -> Result<i16, io::Error> {
60
122k
        let mut n = [0u8; 2];
61
122k
        self.reader.read_exact(&mut n)?;
62
122k
        Ok(match self.byte_order {
63
120k
            ByteOrder::LittleEndian => i16::from_le_bytes(n),
64
2.17k
            ByteOrder::BigEndian => i16::from_be_bytes(n),
65
        })
66
122k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Line
Count
Source
59
122k
    pub fn read_i16(&mut self) -> Result<i16, io::Error> {
60
122k
        let mut n = [0u8; 2];
61
122k
        self.reader.read_exact(&mut n)?;
62
122k
        Ok(match self.byte_order {
63
120k
            ByteOrder::LittleEndian => i16::from_le_bytes(n),
64
2.05k
            ByteOrder::BigEndian => i16::from_be_bytes(n),
65
        })
66
122k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i16
Line
Count
Source
59
1
    pub fn read_i16(&mut self) -> Result<i16, io::Error> {
60
1
        let mut n = [0u8; 2];
61
1
        self.reader.read_exact(&mut n)?;
62
1
        Ok(match self.byte_order {
63
1
            ByteOrder::LittleEndian => i16::from_le_bytes(n),
64
0
            ByteOrder::BigEndian => i16::from_be_bytes(n),
65
        })
66
1
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i16
Line
Count
Source
59
129
    pub fn read_i16(&mut self) -> Result<i16, io::Error> {
60
129
        let mut n = [0u8; 2];
61
129
        self.reader.read_exact(&mut n)?;
62
128
        Ok(match self.byte_order {
63
0
            ByteOrder::LittleEndian => i16::from_le_bytes(n),
64
128
            ByteOrder::BigEndian => i16::from_be_bytes(n),
65
        })
66
129
    }
67
68
    /// Reads an u32
69
    #[inline(always)]
70
3.05M
    pub fn read_u32(&mut self) -> Result<u32, io::Error> {
71
3.05M
        let mut n = [0u8; 4];
72
3.05M
        self.reader.read_exact(&mut n)?;
73
3.05M
        Ok(match self.byte_order {
74
2.39M
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
75
651k
            ByteOrder::BigEndian => u32::from_be_bytes(n),
76
        })
77
3.05M
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_u32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Line
Count
Source
70
1.67M
    pub fn read_u32(&mut self) -> Result<u32, io::Error> {
71
1.67M
        let mut n = [0u8; 4];
72
1.67M
        self.reader.read_exact(&mut n)?;
73
1.67M
        Ok(match self.byte_order {
74
1.26M
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
75
409k
            ByteOrder::BigEndian => u32::from_be_bytes(n),
76
        })
77
1.67M
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Line
Count
Source
70
5.57k
    pub fn read_u32(&mut self) -> Result<u32, io::Error> {
71
5.57k
        let mut n = [0u8; 4];
72
5.57k
        self.reader.read_exact(&mut n)?;
73
5.57k
        Ok(match self.byte_order {
74
5.46k
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
75
112
            ByteOrder::BigEndian => u32::from_be_bytes(n),
76
        })
77
5.57k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u32
Line
Count
Source
70
1.36M
    pub fn read_u32(&mut self) -> Result<u32, io::Error> {
71
1.36M
        let mut n = [0u8; 4];
72
1.36M
        self.reader.read_exact(&mut n)?;
73
1.36M
        Ok(match self.byte_order {
74
1.12M
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
75
242k
            ByteOrder::BigEndian => u32::from_be_bytes(n),
76
        })
77
1.36M
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u32
Line
Count
Source
70
6.74k
    pub fn read_u32(&mut self) -> Result<u32, io::Error> {
71
6.74k
        let mut n = [0u8; 4];
72
6.74k
        self.reader.read_exact(&mut n)?;
73
6.74k
        Ok(match self.byte_order {
74
6.57k
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
75
174
            ByteOrder::BigEndian => u32::from_be_bytes(n),
76
        })
77
6.74k
    }
78
79
    /// Reads an i32
80
    #[inline(always)]
81
180k
    pub fn read_i32(&mut self) -> Result<i32, io::Error> {
82
180k
        let mut n = [0u8; 4];
83
180k
        self.reader.read_exact(&mut n)?;
84
180k
        Ok(match self.byte_order {
85
180k
            ByteOrder::LittleEndian => i32::from_le_bytes(n),
86
703
            ByteOrder::BigEndian => i32::from_be_bytes(n),
87
        })
88
180k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Line
Count
Source
81
180k
    pub fn read_i32(&mut self) -> Result<i32, io::Error> {
82
180k
        let mut n = [0u8; 4];
83
180k
        self.reader.read_exact(&mut n)?;
84
180k
        Ok(match self.byte_order {
85
179k
            ByteOrder::LittleEndian => i32::from_le_bytes(n),
86
511
            ByteOrder::BigEndian => i32::from_be_bytes(n),
87
        })
88
180k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i32
Line
Count
Source
81
776
    pub fn read_i32(&mut self) -> Result<i32, io::Error> {
82
776
        let mut n = [0u8; 4];
83
776
        self.reader.read_exact(&mut n)?;
84
769
        Ok(match self.byte_order {
85
577
            ByteOrder::LittleEndian => i32::from_le_bytes(n),
86
192
            ByteOrder::BigEndian => i32::from_be_bytes(n),
87
        })
88
776
    }
89
90
    /// Reads an u64
91
    #[inline(always)]
92
182k
    pub fn read_u64(&mut self) -> Result<u64, io::Error> {
93
182k
        let mut n = [0u8; 8];
94
182k
        self.reader.read_exact(&mut n)?;
95
182k
        Ok(match self.byte_order {
96
95.1k
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
97
86.9k
            ByteOrder::BigEndian => u64::from_be_bytes(n),
98
        })
99
182k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_u64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Line
Count
Source
92
173k
    pub fn read_u64(&mut self) -> Result<u64, io::Error> {
93
173k
        let mut n = [0u8; 8];
94
173k
        self.reader.read_exact(&mut n)?;
95
173k
        Ok(match self.byte_order {
96
86.2k
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
97
86.8k
            ByteOrder::BigEndian => u64::from_be_bytes(n),
98
        })
99
173k
    }
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Line
Count
Source
92
12
    pub fn read_u64(&mut self) -> Result<u64, io::Error> {
93
12
        let mut n = [0u8; 8];
94
12
        self.reader.read_exact(&mut n)?;
95
12
        Ok(match self.byte_order {
96
8
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
97
4
            ByteOrder::BigEndian => u64::from_be_bytes(n),
98
        })
99
12
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_u64
Line
Count
Source
92
8.91k
    pub fn read_u64(&mut self) -> Result<u64, io::Error> {
93
8.91k
        let mut n = [0u8; 8];
94
8.91k
        self.reader.read_exact(&mut n)?;
95
8.90k
        Ok(match self.byte_order {
96
8.87k
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
97
33
            ByteOrder::BigEndian => u64::from_be_bytes(n),
98
        })
99
8.91k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_u64
100
101
    /// Reads an i64
102
    #[inline(always)]
103
498
    pub fn read_i64(&mut self) -> Result<i64, io::Error> {
104
498
        let mut n = [0u8; 8];
105
498
        self.reader.read_exact(&mut n)?;
106
492
        Ok(match self.byte_order {
107
204
            ByteOrder::LittleEndian => i64::from_le_bytes(n),
108
288
            ByteOrder::BigEndian => i64::from_be_bytes(n),
109
        })
110
498
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Line
Count
Source
103
333
    pub fn read_i64(&mut self) -> Result<i64, io::Error> {
104
333
        let mut n = [0u8; 8];
105
333
        self.reader.read_exact(&mut n)?;
106
329
        Ok(match self.byte_order {
107
73
            ByteOrder::LittleEndian => i64::from_le_bytes(n),
108
256
            ByteOrder::BigEndian => i64::from_be_bytes(n),
109
        })
110
333
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_i64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_i64
Line
Count
Source
103
165
    pub fn read_i64(&mut self) -> Result<i64, io::Error> {
104
165
        let mut n = [0u8; 8];
105
165
        self.reader.read_exact(&mut n)?;
106
163
        Ok(match self.byte_order {
107
131
            ByteOrder::LittleEndian => i64::from_le_bytes(n),
108
32
            ByteOrder::BigEndian => i64::from_be_bytes(n),
109
        })
110
165
    }
111
112
    /// Reads an f32
113
    #[inline(always)]
114
51.1k
    pub fn read_f32(&mut self) -> Result<f32, io::Error> {
115
51.1k
        let mut n = [0u8; 4];
116
51.1k
        self.reader.read_exact(&mut n)?;
117
51.1k
        Ok(f32::from_bits(match self.byte_order {
118
2.42k
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
119
48.7k
            ByteOrder::BigEndian => u32::from_be_bytes(n),
120
        }))
121
51.1k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Line
Count
Source
114
48.8k
    pub fn read_f32(&mut self) -> Result<f32, io::Error> {
115
48.8k
        let mut n = [0u8; 4];
116
48.8k
        self.reader.read_exact(&mut n)?;
117
48.8k
        Ok(f32::from_bits(match self.byte_order {
118
128
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
119
48.7k
            ByteOrder::BigEndian => u32::from_be_bytes(n),
120
        }))
121
48.8k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f32
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f32
Line
Count
Source
114
2.30k
    pub fn read_f32(&mut self) -> Result<f32, io::Error> {
115
2.30k
        let mut n = [0u8; 4];
116
2.30k
        self.reader.read_exact(&mut n)?;
117
2.29k
        Ok(f32::from_bits(match self.byte_order {
118
2.29k
            ByteOrder::LittleEndian => u32::from_le_bytes(n),
119
0
            ByteOrder::BigEndian => u32::from_be_bytes(n),
120
        }))
121
2.30k
    }
122
123
    /// Reads an f64
124
    #[inline(always)]
125
1.02k
    pub fn read_f64(&mut self) -> Result<f64, io::Error> {
126
1.02k
        let mut n = [0u8; 8];
127
1.02k
        self.reader.read_exact(&mut n)?;
128
1.01k
        Ok(f64::from_bits(match self.byte_order {
129
854
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
130
160
            ByteOrder::BigEndian => u64::from_be_bytes(n),
131
        }))
132
1.02k
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<_>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Line
Count
Source
125
851
    pub fn read_f64(&mut self) -> Result<f64, io::Error> {
126
851
        let mut n = [0u8; 8];
127
851
        self.reader.read_exact(&mut n)?;
128
846
        Ok(f64::from_bits(match self.byte_order {
129
718
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
130
128
            ByteOrder::BigEndian => u64::from_be_bytes(n),
131
        }))
132
851
    }
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Unexecuted instantiation: <tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<alloc::vec::Vec<u8>>>>::read_f64
<tiff::decoder::stream::EndianReader<std::io::cursor::Cursor<&[u8]>>>::read_f64
Line
Count
Source
125
170
    pub fn read_f64(&mut self) -> Result<f64, io::Error> {
126
170
        let mut n = [0u8; 8];
127
170
        self.reader.read_exact(&mut n)?;
128
168
        Ok(f64::from_bits(match self.byte_order {
129
136
            ByteOrder::LittleEndian => u64::from_le_bytes(n),
130
32
            ByteOrder::BigEndian => u64::from_be_bytes(n),
131
        }))
132
170
    }
133
}
134
135
///
136
/// # READERS
137
///
138
139
///
140
/// ## Deflate Reader
141
///
142
143
#[cfg(feature = "deflate")]
144
pub type DeflateReader<R> = flate2::read::ZlibDecoder<R>;
145
146
///
147
/// ## LZW Reader
148
///
149
150
/// Reader that decompresses LZW streams
151
#[cfg(feature = "lzw")]
152
pub struct LZWReader<R: Read> {
153
    reader: BufReader<Take<R>>,
154
    decoder: weezl::decode::Decoder,
155
}
156
157
#[cfg(feature = "lzw")]
158
impl<R: Read> LZWReader<R> {
159
    /// Wraps a reader
160
1.29k
    pub fn new(reader: R, compressed_length: usize) -> LZWReader<R> {
161
1.29k
        Self {
162
1.29k
            reader: BufReader::with_capacity(
163
1.29k
                (32 * 1024).min(compressed_length),
164
1.29k
                reader.take(u64::try_from(compressed_length).unwrap()),
165
1.29k
            ),
166
1.29k
            decoder: weezl::decode::Decoder::with_tiff_size_switch(weezl::BitOrder::Msb, 8),
167
1.29k
        }
168
1.29k
    }
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<_>>::new
<tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
160
543
    pub fn new(reader: R, compressed_length: usize) -> LZWReader<R> {
161
543
        Self {
162
543
            reader: BufReader::with_capacity(
163
543
                (32 * 1024).min(compressed_length),
164
543
                reader.take(u64::try_from(compressed_length).unwrap()),
165
543
            ),
166
543
            decoder: weezl::decode::Decoder::with_tiff_size_switch(weezl::BitOrder::Msb, 8),
167
543
        }
168
543
    }
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
<tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
160
752
    pub fn new(reader: R, compressed_length: usize) -> LZWReader<R> {
161
752
        Self {
162
752
            reader: BufReader::with_capacity(
163
752
                (32 * 1024).min(compressed_length),
164
752
                reader.take(u64::try_from(compressed_length).unwrap()),
165
752
            ),
166
752
            decoder: weezl::decode::Decoder::with_tiff_size_switch(weezl::BitOrder::Msb, 8),
167
752
        }
168
752
    }
169
}
170
171
#[cfg(feature = "lzw")]
172
impl<R: Read> Read for LZWReader<R> {
173
120k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
174
        loop {
175
121k
            let result = self.decoder.decode_bytes(self.reader.fill_buf()?, buf);
176
121k
            self.reader.consume(result.consumed_in);
177
178
121k
            match result.status {
179
                Ok(weezl::LzwStatus::Ok) => {
180
120k
                    if result.consumed_out == 0 {
181
1.10k
                        continue;
182
                    } else {
183
119k
                        return Ok(result.consumed_out);
184
                    }
185
                }
186
                Ok(weezl::LzwStatus::NoProgress) => {
187
279
                    assert_eq!(result.consumed_in, 0);
188
279
                    assert_eq!(result.consumed_out, 0);
189
279
                    assert!(self.reader.buffer().is_empty());
190
279
                    return Err(io::Error::new(
191
279
                        io::ErrorKind::UnexpectedEof,
192
279
                        "no lzw end code found",
193
279
                    ));
194
                }
195
                Ok(weezl::LzwStatus::Done) => {
196
611
                    return Ok(result.consumed_out);
197
                }
198
330
                Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidData, err)),
199
            }
200
        }
201
120k
    }
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<_> as std::io::Read>::read
<tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Line
Count
Source
173
64.2k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
174
        loop {
175
64.7k
            let result = self.decoder.decode_bytes(self.reader.fill_buf()?, buf);
176
64.7k
            self.reader.consume(result.consumed_in);
177
178
64.5k
            match result.status {
179
                Ok(weezl::LzwStatus::Ok) => {
180
64.2k
                    if result.consumed_out == 0 {
181
477
                        continue;
182
                    } else {
183
63.7k
                        return Ok(result.consumed_out);
184
                    }
185
                }
186
                Ok(weezl::LzwStatus::NoProgress) => {
187
112
                    assert_eq!(result.consumed_in, 0);
188
112
                    assert_eq!(result.consumed_out, 0);
189
112
                    assert!(self.reader.buffer().is_empty());
190
112
                    return Err(io::Error::new(
191
112
                        io::ErrorKind::UnexpectedEof,
192
112
                        "no lzw end code found",
193
112
                    ));
194
                }
195
                Ok(weezl::LzwStatus::Done) => {
196
273
                    return Ok(result.consumed_out);
197
                }
198
126
                Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidData, err)),
199
            }
200
        }
201
64.2k
    }
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
<tiff::decoder::stream::LZWReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Line
Count
Source
173
56.3k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
174
        loop {
175
56.9k
            let result = self.decoder.decode_bytes(self.reader.fill_buf()?, buf);
176
56.9k
            self.reader.consume(result.consumed_in);
177
178
56.7k
            match result.status {
179
                Ok(weezl::LzwStatus::Ok) => {
180
56.2k
                    if result.consumed_out == 0 {
181
626
                        continue;
182
                    } else {
183
55.6k
                        return Ok(result.consumed_out);
184
                    }
185
                }
186
                Ok(weezl::LzwStatus::NoProgress) => {
187
167
                    assert_eq!(result.consumed_in, 0);
188
167
                    assert_eq!(result.consumed_out, 0);
189
167
                    assert!(self.reader.buffer().is_empty());
190
167
                    return Err(io::Error::new(
191
167
                        io::ErrorKind::UnexpectedEof,
192
167
                        "no lzw end code found",
193
167
                    ));
194
                }
195
                Ok(weezl::LzwStatus::Done) => {
196
338
                    return Ok(result.consumed_out);
197
                }
198
204
                Err(err) => return Err(io::Error::new(io::ErrorKind::InvalidData, err)),
199
            }
200
        }
201
56.3k
    }
202
}
203
204
///
205
/// ## PackBits Reader
206
///
207
208
enum PackBitsReaderState {
209
    Header,
210
    Literal,
211
    Repeat { value: u8 },
212
}
213
214
/// Reader that unpacks Apple's `PackBits` format
215
pub struct PackBitsReader<R: Read> {
216
    reader: Take<R>,
217
    state: PackBitsReaderState,
218
    count: usize,
219
}
220
221
impl<R: Read> PackBitsReader<R> {
222
    /// Wraps a reader
223
341
    pub fn new(reader: R, length: u64) -> Self {
224
341
        Self {
225
341
            reader: reader.take(length),
226
341
            state: PackBitsReaderState::Header,
227
341
            count: 0,
228
341
        }
229
341
    }
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<_>>::new
<tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
223
54
    pub fn new(reader: R, length: u64) -> Self {
224
54
        Self {
225
54
            reader: reader.take(length),
226
54
            state: PackBitsReaderState::Header,
227
54
            count: 0,
228
54
        }
229
54
    }
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
<tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>>>::new
Line
Count
Source
223
287
    pub fn new(reader: R, length: u64) -> Self {
224
287
        Self {
225
287
            reader: reader.take(length),
226
287
            state: PackBitsReaderState::Header,
227
287
            count: 0,
228
287
        }
229
287
    }
230
}
231
232
impl<R: Read> Read for PackBitsReader<R> {
233
176k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
234
344k
        while let PackBitsReaderState::Header = self.state {
235
168k
            if self.reader.limit() == 0 {
236
6
                return Ok(0);
237
168k
            }
238
168k
            let mut header: [u8; 1] = [0];
239
168k
            self.reader.read_exact(&mut header)?;
240
168k
            let h = header[0] as i8;
241
168k
            if (-127..=-1).contains(&h) {
242
72.3k
                let mut data: [u8; 1] = [0];
243
72.3k
                self.reader.read_exact(&mut data)?;
244
72.3k
                self.state = PackBitsReaderState::Repeat { value: data[0] };
245
72.3k
                self.count = (1 - h as isize) as usize;
246
95.6k
            } else if h >= 0 {
247
94.6k
                self.state = PackBitsReaderState::Literal;
248
94.6k
                self.count = h as usize + 1;
249
94.6k
            } else {
250
1.02k
                // h = -128 is a no-op.
251
1.02k
            }
252
        }
253
254
176k
        let length = buf.len().min(self.count);
255
176k
        let actual = match self.state {
256
97.1k
            PackBitsReaderState::Literal => self.reader.read(&mut buf[..length])?,
257
78.9k
            PackBitsReaderState::Repeat { value } => {
258
3.66M
                for b in &mut buf[..length] {
259
3.66M
                    *b = value;
260
3.66M
                }
261
262
78.9k
                length
263
            }
264
0
            PackBitsReaderState::Header => unreachable!(),
265
        };
266
267
176k
        self.count -= actual;
268
176k
        if self.count == 0 {
269
166k
            self.state = PackBitsReaderState::Header;
270
166k
        }
271
176k
        Ok(actual)
272
176k
    }
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<_> as std::io::Read>::read
<tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Line
Count
Source
233
103k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
234
202k
        while let PackBitsReaderState::Header = self.state {
235
99.8k
            if self.reader.limit() == 0 {
236
3
                return Ok(0);
237
99.8k
            }
238
99.8k
            let mut header: [u8; 1] = [0];
239
99.8k
            self.reader.read_exact(&mut header)?;
240
99.8k
            let h = header[0] as i8;
241
99.8k
            if (-127..=-1).contains(&h) {
242
35.4k
                let mut data: [u8; 1] = [0];
243
35.4k
                self.reader.read_exact(&mut data)?;
244
35.4k
                self.state = PackBitsReaderState::Repeat { value: data[0] };
245
35.4k
                self.count = (1 - h as isize) as usize;
246
64.3k
            } else if h >= 0 {
247
63.8k
                self.state = PackBitsReaderState::Literal;
248
63.8k
                self.count = h as usize + 1;
249
63.8k
            } else {
250
583
                // h = -128 is a no-op.
251
583
            }
252
        }
253
254
103k
        let length = buf.len().min(self.count);
255
103k
        let actual = match self.state {
256
65.5k
            PackBitsReaderState::Literal => self.reader.read(&mut buf[..length])?,
257
37.5k
            PackBitsReaderState::Repeat { value } => {
258
2.34M
                for b in &mut buf[..length] {
259
2.34M
                    *b = value;
260
2.34M
                }
261
262
37.5k
                length
263
            }
264
0
            PackBitsReaderState::Header => unreachable!(),
265
        };
266
267
103k
        self.count -= actual;
268
103k
        if self.count == 0 {
269
99.2k
            self.state = PackBitsReaderState::Header;
270
99.2k
        }
271
103k
        Ok(actual)
272
103k
    }
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Unexecuted instantiation: <tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
<tiff::decoder::stream::PackBitsReader<&mut std::io::cursor::Cursor<&[u8]>> as std::io::Read>::read
Line
Count
Source
233
72.9k
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
234
141k
        while let PackBitsReaderState::Header = self.state {
235
68.3k
            if self.reader.limit() == 0 {
236
3
                return Ok(0);
237
68.3k
            }
238
68.3k
            let mut header: [u8; 1] = [0];
239
68.3k
            self.reader.read_exact(&mut header)?;
240
68.2k
            let h = header[0] as i8;
241
68.2k
            if (-127..=-1).contains(&h) {
242
36.9k
                let mut data: [u8; 1] = [0];
243
36.9k
                self.reader.read_exact(&mut data)?;
244
36.9k
                self.state = PackBitsReaderState::Repeat { value: data[0] };
245
36.9k
                self.count = (1 - h as isize) as usize;
246
31.3k
            } else if h >= 0 {
247
30.8k
                self.state = PackBitsReaderState::Literal;
248
30.8k
                self.count = h as usize + 1;
249
30.8k
            } else {
250
443
                // h = -128 is a no-op.
251
443
            }
252
        }
253
254
72.9k
        let length = buf.len().min(self.count);
255
72.9k
        let actual = match self.state {
256
31.5k
            PackBitsReaderState::Literal => self.reader.read(&mut buf[..length])?,
257
41.3k
            PackBitsReaderState::Repeat { value } => {
258
1.32M
                for b in &mut buf[..length] {
259
1.32M
                    *b = value;
260
1.32M
                }
261
262
41.3k
                length
263
            }
264
0
            PackBitsReaderState::Header => unreachable!(),
265
        };
266
267
72.9k
        self.count -= actual;
268
72.9k
        if self.count == 0 {
269
67.6k
            self.state = PackBitsReaderState::Header;
270
67.6k
        }
271
72.9k
        Ok(actual)
272
72.9k
    }
273
}
274
275
#[cfg(test)]
276
mod test {
277
    use super::*;
278
279
    #[test]
280
    fn test_packbits() {
281
        let encoded = vec![
282
            0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7,
283
            0xAA,
284
        ];
285
        let encoded_len = encoded.len();
286
287
        let buff = io::Cursor::new(encoded);
288
        let mut decoder = PackBitsReader::new(buff, encoded_len as u64);
289
290
        let mut decoded = Vec::new();
291
        decoder.read_to_end(&mut decoded).unwrap();
292
293
        let expected = vec![
294
            0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0x22,
295
            0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
296
        ];
297
        assert_eq!(decoded, expected);
298
    }
299
}