Decode a range of blocks [start_block..end_block) from encoded data. More efficient than calling `decode_single_block` repeatedly — scans headers once to find start_block, then decodes contiguously.
(
data: &[u8],
start_block: usize,
end_block: usize,
)
| 128 | /// More efficient than calling `decode_single_block` repeatedly — scans |
| 129 | /// headers once to find start_block, then decodes contiguously. |
| 130 | pub fn decode_block_range( |
| 131 | data: &[u8], |
| 132 | start_block: usize, |
| 133 | end_block: usize, |
| 134 | ) -> Result<Vec<i64>, CodecError> { |
| 135 | if data.len() < GLOBAL_HEADER_SIZE { |
| 136 | return Err(CodecError::Truncated { |
| 137 | expected: GLOBAL_HEADER_SIZE, |
| 138 | actual: data.len(), |
| 139 | }); |
| 140 | } |
| 141 | let num_blocks = u16::from_le_bytes([data[4], data[5]]) as usize; |
| 142 | if start_block >= num_blocks || end_block > num_blocks || start_block >= end_block { |
| 143 | return Ok(Vec::new()); |
| 144 | } |
| 145 | |
| 146 | // Skip to start_block. |
| 147 | let mut offset = GLOBAL_HEADER_SIZE; |
| 148 | for i in 0..start_block { |
| 149 | offset = skip_block(data, offset, i)?; |
| 150 | } |
| 151 | |
| 152 | // Decode [start_block..end_block). |
| 153 | let mut values = Vec::new(); |
| 154 | for i in start_block..end_block { |
| 155 | offset = decode_block(data, offset, &mut values, i)?; |
| 156 | } |
| 157 | Ok(values) |
| 158 | } |
| 159 | |
| 160 | /// Number of blocks in an encoded FastLanes stream. |
| 161 | pub fn block_count(data: &[u8]) -> Result<usize, CodecError> { |
nothing calls this directly
no test coverage detected