|
1 | 1 | // special thanks to james7132 |
2 | 2 |
|
3 | | -pub(crate) fn encode<'a>(reference: &[u8], pending_input: impl Iterator<Item = &'a Vec<u8>>) -> Vec<u8> { |
| 3 | +pub(crate) fn encode<'a>( |
| 4 | + reference: &[u8], |
| 5 | + pending_input: impl Iterator<Item = &'a Vec<u8>>, |
| 6 | +) -> Vec<u8> { |
4 | 7 | // first, do a XOR encoding to the reference input (will probably lead to a lot of same bits in sequence) |
5 | 8 | let buf = delta_encode(reference, pending_input); |
6 | 9 | // then, RLE encode the buffer (making use of the property mentioned above) |
@@ -131,9 +134,9 @@ mod compression_tests { |
131 | 134 | // simulate an enum whose variants serialize to different sizes |
132 | 135 | let reference = vec![0u8; 1]; |
133 | 136 | let inputs = vec![ |
134 | | - vec![1u8], // 1 byte variant |
135 | | - vec![2u8, 10, 20], // 3 byte variant |
136 | | - vec![1u8], // back to 1 byte |
| 137 | + vec![1u8], // 1 byte variant |
| 138 | + vec![2u8, 10, 20], // 3 byte variant |
| 139 | + vec![1u8], // back to 1 byte |
137 | 140 | vec![3u8, 1, 2, 3, 4, 5], // 6 byte variant |
138 | 141 | ]; |
139 | 142 | let encoded = encode(&reference, inputs.iter()); |
|
0 commit comments