Skip to content

Commit

Permalink
Implement PrimitiveValueDecoder::decode for ByteRleDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed Sep 28, 2024
1 parent 63c7513 commit ecffdf8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/encoding/byte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,19 @@ impl<R: Read> Iterator for ByteRleDecoder<R> {
}
}

impl<R: Read> PrimitiveValueDecoder<i8> for ByteRleDecoder<R> {}
impl<R: Read> PrimitiveValueDecoder<i8> for ByteRleDecoder<R> {
// TODO: can probably implement this better, just copying from iter for now
fn decode(&mut self, out: &mut [i8]) -> Result<()> {
for x in out.iter_mut() {
if self.index == self.leftovers.len() {
self.read_values()?;
}
*x = self.leftovers[self.index] as i8;
self.index += 1;
}
Ok(())
}
}

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit ecffdf8

Please sign in to comment.