Coverage Report

Created: 2026-12-01 08:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/png-0.18.1/src/traits.rs
Line
Count
Source
1
use std::io;
2
3
macro_rules! read_bytes_ext {
4
    ($output_type:ty) => {
5
        impl<W: io::Read + ?Sized> ReadBytesExt<$output_type> for W {
6
            #[inline]
7
149k
            fn read_be(&mut self) -> io::Result<$output_type> {
8
149k
                let mut bytes = [0u8; std::mem::size_of::<$output_type>()];
9
149k
                self.read_exact(&mut bytes)?;
10
149k
                Ok(<$output_type>::from_be_bytes(bytes))
11
149k
            }
<&[u8] as png::traits::ReadBytesExt<u8>>::read_be
Line
Count
Source
7
111k
            fn read_be(&mut self) -> io::Result<$output_type> {
8
111k
                let mut bytes = [0u8; std::mem::size_of::<$output_type>()];
9
111k
                self.read_exact(&mut bytes)?;
10
111k
                Ok(<$output_type>::from_be_bytes(bytes))
11
111k
            }
<&[u8] as png::traits::ReadBytesExt<u32>>::read_be
Line
Count
Source
7
37.8k
            fn read_be(&mut self) -> io::Result<$output_type> {
8
37.8k
                let mut bytes = [0u8; std::mem::size_of::<$output_type>()];
9
37.8k
                self.read_exact(&mut bytes)?;
10
37.8k
                Ok(<$output_type>::from_be_bytes(bytes))
11
37.8k
            }
<&[u8] as png::traits::ReadBytesExt<u16>>::read_be
Line
Count
Source
7
954
            fn read_be(&mut self) -> io::Result<$output_type> {
8
954
                let mut bytes = [0u8; std::mem::size_of::<$output_type>()];
9
954
                self.read_exact(&mut bytes)?;
10
954
                Ok(<$output_type>::from_be_bytes(bytes))
11
954
            }
12
        }
13
    };
14
}
15
16
macro_rules! write_bytes_ext {
17
    ($input_type:ty) => {
18
        impl<W: io::Write + ?Sized> WriteBytesExt<$input_type> for W {
19
            #[inline]
20
0
            fn write_be(&mut self, n: $input_type) -> io::Result<()> {
21
0
                self.write_all(&n.to_be_bytes())
22
0
            }
Unexecuted instantiation: <&mut &mut alloc::vec::Vec<u8> as png::traits::WriteBytesExt<u32>>::write_be
Unexecuted instantiation: <_ as png::traits::WriteBytesExt<u32>>::write_be
Unexecuted instantiation: <&mut &mut std::io::cursor::Cursor<alloc::vec::Vec<u8>> as png::traits::WriteBytesExt<u32>>::write_be
23
        }
24
    };
25
}
26
27
/// Read extension to read big endian data
28
pub trait ReadBytesExt<T>: io::Read {
29
    /// Read `T` from a bytes stream. Most significant byte first.
30
    fn read_be(&mut self) -> io::Result<T>;
31
}
32
33
/// Write extension to write big endian data
34
pub trait WriteBytesExt<T>: io::Write {
35
    /// Writes `T` to a bytes stream. Most significant byte first.
36
    fn write_be(&mut self, _: T) -> io::Result<()>;
37
}
38
39
read_bytes_ext!(u8);
40
read_bytes_ext!(u16);
41
read_bytes_ext!(u32);
42
43
write_bytes_ext!(u32);