Coverage Report

Created: 2025-12-05 07:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/fax-0.2.6/src/maps.rs
Line
Count
Source
1
use fax_derive::bitmaps;
2
use crate::{BitReader, Bits};
3
4
enum Entry<T: Copy + 'static> {
5
    Leaf(u8, &'static [Option<(T, u8)>]),
6
    Value(T, u8),
7
    Prefix(u8, &'static [Entry<T>])
8
}
9
impl<T: Copy> Entry<T> {
10
6.69M
    fn find(&self, reader: &mut impl BitReader) -> Option<T> {
11
6.69M
        match *self {
12
0
            Entry::Value(val, len) => {
13
0
                reader.consume(len);
14
0
                Some(val)
15
            }
16
544k
            Entry::Leaf(width, lut) => {
17
544k
                let index = reader.peek(width)?;
18
544k
                let (val, len) = lut[index as usize]?;
19
544k
                reader.consume(len);
20
544k
                Some(val)
21
            }
22
6.15M
            Entry::Prefix(width, lut) => {
23
6.15M
                let index = reader.peek(width)?;
24
6.15M
                let entry = &lut[index as usize];
25
6.15M
                match *entry {
26
5.61M
                    Entry::Value(val, len) => {
27
5.61M
                        reader.consume(len);
28
5.61M
                        Some(val)
29
                    }
30
                    _ => {
31
544k
                        reader.consume(width);
32
544k
                        entry.find(reader)
33
                    }
34
                }
35
            }
36
        }
37
6.69M
    }
<fax::maps::Entry<fax::maps::Mode>>::find::<fax::ByteReader<std::io::Bytes<std::io::buffered::bufreader::BufReader<std::io::Take<&mut std::io::cursor::Cursor<&[u8]>>>>>>
Line
Count
Source
10
3.87M
    fn find(&self, reader: &mut impl BitReader) -> Option<T> {
11
3.87M
        match *self {
12
0
            Entry::Value(val, len) => {
13
0
                reader.consume(len);
14
0
                Some(val)
15
            }
16
0
            Entry::Leaf(width, lut) => {
17
0
                let index = reader.peek(width)?;
18
0
                let (val, len) = lut[index as usize]?;
19
0
                reader.consume(len);
20
0
                Some(val)
21
            }
22
3.87M
            Entry::Prefix(width, lut) => {
23
3.87M
                let index = reader.peek(width)?;
24
3.87M
                let entry = &lut[index as usize];
25
3.87M
                match *entry {
26
3.87M
                    Entry::Value(val, len) => {
27
3.87M
                        reader.consume(len);
28
3.87M
                        Some(val)
29
                    }
30
                    _ => {
31
0
                        reader.consume(width);
32
0
                        entry.find(reader)
33
                    }
34
                }
35
            }
36
        }
37
3.87M
    }
<fax::maps::Entry<u16>>::find::<fax::ByteReader<std::io::Bytes<std::io::buffered::bufreader::BufReader<std::io::Take<&mut std::io::cursor::Cursor<&[u8]>>>>>>
Line
Count
Source
10
2.82M
    fn find(&self, reader: &mut impl BitReader) -> Option<T> {
11
2.82M
        match *self {
12
0
            Entry::Value(val, len) => {
13
0
                reader.consume(len);
14
0
                Some(val)
15
            }
16
544k
            Entry::Leaf(width, lut) => {
17
544k
                let index = reader.peek(width)?;
18
544k
                let (val, len) = lut[index as usize]?;
19
544k
                reader.consume(len);
20
544k
                Some(val)
21
            }
22
2.27M
            Entry::Prefix(width, lut) => {
23
2.27M
                let index = reader.peek(width)?;
24
2.27M
                let entry = &lut[index as usize];
25
2.27M
                match *entry {
26
1.73M
                    Entry::Value(val, len) => {
27
1.73M
                        reader.consume(len);
28
1.73M
                        Some(val)
29
                    }
30
                    _ => {
31
544k
                        reader.consume(width);
32
544k
                        entry.find(reader)
33
                    }
34
                }
35
            }
36
        }
37
2.82M
    }
Unexecuted instantiation: <fax::maps::Entry<_>>::find::<_>
38
}
39
40
pub const EDFB_HALF: Bits = Bits { data: 1, len: 12 };
41
pub const EOL: Bits = Bits { data: 1, len: 12 };
42
43
#[derive(Copy, Clone, Debug)]
44
pub enum Mode {
45
    Pass,
46
    Horizontal,
47
    Vertical(i8),
48
    Extension,
49
    EOF,
50
}
51
52
bitmaps! {
53
    mode <Mode> {
54
        0001 => Mode::Pass,
55
        001 => Mode::Horizontal,
56
        1 => Mode::Vertical(0),
57
        011 => Mode::Vertical(1),
58
        000011 => Mode::Vertical(2),
59
        0000011 => Mode::Vertical(3),
60
        010 => Mode::Vertical(-1),
61
        000010 => Mode::Vertical(-2),
62
        0000010 => Mode::Vertical(-3),
63
        0000001 => Mode::Extension,
64
        000000000001 => Mode::EOF,
65
    },
66
    black {
67
        0000110111 => 0,
68
        010 => 1,
69
        11 => 2,
70
        10 => 3,
71
        011 => 4,
72
        0011 => 5,
73
        0010 => 6,
74
        00011 => 7,
75
        000101 => 8,
76
        000100 => 9,
77
        0000100 => 10,
78
        0000101 => 11,
79
        0000111 => 12,
80
        00000100 => 13,
81
        00000111 => 14,
82
        000011000 => 15,
83
        0000010111 => 16,
84
        0000011000 => 17,
85
        0000001000 => 18,
86
        00001100111 => 19,
87
        00001101000 => 20,
88
        00001101100 => 21,
89
        00000110111 => 22,
90
        00000101000 => 23,
91
        00000010111 => 24,
92
        00000011000 => 25,
93
        000011001010 => 26,
94
        000011001011 => 27,
95
        000011001100 => 28,
96
        000011001101 => 29,
97
        000001101000 => 30,
98
        000001101001 => 31,
99
        000001101010 => 32,
100
        000001101011 => 33,
101
        000011010010 => 34,
102
        000011010011 => 35,
103
        000011010100 => 36,
104
        000011010101 => 37,
105
        000011010110 => 38,
106
        000011010111 => 39,
107
        000001101100 => 40,
108
        000001101101 => 41,
109
        000011011010 => 42,
110
        000011011011 => 43,
111
        000001010100 => 44,
112
        000001010101 => 45,
113
        000001010110 => 46,
114
        000001010111 => 47,
115
        000001100100 => 48,
116
        000001100101 => 49,
117
        000001010010 => 50,
118
        000001010011 => 51,
119
        000000100100 => 52,
120
        000000110111 => 53,
121
        000000111000 => 54,
122
        000000100111 => 55,
123
        000000101000 => 56,
124
        000001011000 => 57,
125
        000001011001 => 58,
126
        000000101011 => 59,
127
        000000101100 => 60,
128
        000001011010 => 61,
129
        000001100110 => 62,
130
        000001100111 => 63,
131
        0000001111 => 64,
132
        000011001000 => 128,
133
        000011001001 => 192,
134
        000001011011 => 256,
135
        000000110011 => 320,
136
        000000110100 => 384,
137
        000000110101 => 448,
138
        0000001101100 => 512,
139
        0000001101101 => 576,
140
        0000001001010 => 640,
141
        0000001001011 => 704,
142
        0000001001100 => 768,
143
        0000001001101 => 832,
144
        0000001110010 => 896,
145
        0000001110011 => 960,
146
        0000001110100 => 1024,
147
        0000001110101 => 1088,
148
        0000001110110 => 1152,
149
        0000001110111 => 1216,
150
        0000001010010 => 1280,
151
        0000001010011 => 1344,
152
        0000001010100 => 1408,
153
        0000001010101 => 1472,
154
        0000001011010 => 1536,
155
        0000001011011 => 1600,
156
        0000001100100 => 1664,
157
        0000001100101 => 1728,
158
        00000001000 => 1792,
159
        00000001100 => 1856,
160
        00000001101 => 1920,
161
        000000010010 => 1984,
162
        000000010011 => 2048,
163
        000000010100 => 2112,
164
        000000010101 => 2176,
165
        000000010110 => 2240,
166
        000000010111 => 2304,
167
        000000011100 => 2368,
168
        000000011101 => 2432,
169
        000000011110 => 2496,
170
        000000011111 => 2560,
171
    },
172
    white {
173
        00110101 => 0,
174
        000111 => 1,
175
        0111 => 2,
176
        1000 => 3,
177
        1011 => 4,
178
        1100 => 5,
179
        1110 => 6,
180
        1111 => 7,
181
        10011 => 8,
182
        10100 => 9,
183
        00111 => 10,
184
        01000 => 11,
185
        001000 => 12,
186
        000011 => 13,
187
        110100 => 14,
188
        110101 => 15,
189
        101010 => 16,
190
        101011 => 17,
191
        0100111 => 18,
192
        0001100 => 19,
193
        0001000 => 20,
194
        0010111 => 21,
195
        0000011 => 22,
196
        0000100 => 23,
197
        0101000 => 24,
198
        0101011 => 25,
199
        0010011 => 26,
200
        0100100 => 27,
201
        0011000 => 28,
202
        00000010 => 29,
203
        00000011 => 30,
204
        00011010 => 31,
205
        00011011 => 32,
206
        00010010 => 33,
207
        00010011 => 34,
208
        00010100 => 35,
209
        00010101 => 36,
210
        00010110 => 37,
211
        00010111 => 38,
212
        00101000 => 39,
213
        00101001 => 40,
214
        00101010 => 41,
215
        00101011 => 42,
216
        00101100 => 43,
217
        00101101 => 44,
218
        00000100 => 45,
219
        00000101 => 46,
220
        00001010 => 47,
221
        00001011 => 48,
222
        01010010 => 49,
223
        01010011 => 50,
224
        01010100 => 51,
225
        01010101 => 52,
226
        00100100 => 53,
227
        00100101 => 54,
228
        01011000 => 55,
229
        01011001 => 56,
230
        01011010 => 57,
231
        01011011 => 58,
232
        01001010 => 59,
233
        01001011 => 60,
234
        00110010 => 61,
235
        00110011 => 62,
236
        00110100 => 63,
237
        11011 => 64,
238
        10010 => 128,
239
        010111 => 192,
240
        0110111 => 256,
241
        00110110 => 320,
242
        00110111 => 384,
243
        01100100 => 448,
244
        01100101 => 512,
245
        01101000 => 576,
246
        01100111 => 640,
247
        011001100 => 704,
248
        011001101 => 768,
249
        011010010 => 832,
250
        011010011 => 896,
251
        011010100 => 960,
252
        011010101 => 1024,
253
        011010110 => 1088,
254
        011010111 => 1152,
255
        011011000 => 1216,
256
        011011001 => 1280,
257
        011011010 => 1344,
258
        011011011 => 1408,
259
        010011000 => 1472,
260
        010011001 => 1536,
261
        010011010 => 1600,
262
        011000 => 1664,
263
        010011011 => 1728,
264
        00000001000 => 1792,
265
        00000001100 => 1856,
266
        00000001101 => 1920,
267
        000000010010 => 1984,
268
        000000010011 => 2048,
269
        000000010100 => 2112,
270
        000000010101 => 2176,
271
        000000010110 => 2240,
272
        000000010111 => 2304,
273
        000000011100 => 2368,
274
        000000011101 => 2432,
275
        000000011110 => 2496,
276
        000000011111 => 2560,
277
    },
278
6.15M
}
fax::maps::white::decode::<fax::ByteReader<std::io::Bytes<std::io::buffered::bufreader::BufReader<std::io::Take<&mut std::io::cursor::Cursor<&[u8]>>>>>>
Line
Count
Source
278
1.15M
}
fax::maps::black::decode::<fax::ByteReader<std::io::Bytes<std::io::buffered::bufreader::BufReader<std::io::Take<&mut std::io::cursor::Cursor<&[u8]>>>>>>
Line
Count
Source
278
1.12M
}
fax::maps::mode::decode::<fax::ByteReader<std::io::Bytes<std::io::buffered::bufreader::BufReader<std::io::Take<&mut std::io::cursor::Cursor<&[u8]>>>>>>
Line
Count
Source
278
3.87M
}
Unexecuted instantiation: fax::maps::mode::encode
Unexecuted instantiation: fax::maps::black::encode
Unexecuted instantiation: fax::maps::white::encode
Unexecuted instantiation: fax::maps::mode::decode::<_>
Unexecuted instantiation: fax::maps::black::decode::<_>
Unexecuted instantiation: fax::maps::white::decode::<_>
279