aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2021-11-01 18:16:17 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2021-11-01 18:16:17 +0100
commitbc23de6bedc2e151caea241b073a65d30f62c134 (patch)
treec0f6a1e2cfcdaa1cce0676d03c3efe3d3ae70e54
parentb9995c2ca73cb50f1e9f2ad7a08c49b20135b041 (diff)
downloadnihav-bc23de6bedc2e151caea241b073a65d30f62c134.tar.gz
core/compr: allow inflate work with a custom dictionary
-rw-r--r--nihav-core/src/compr/deflate.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/nihav-core/src/compr/deflate.rs b/nihav-core/src/compr/deflate.rs
index 7b36ead..b126661 100644
--- a/nihav-core/src/compr/deflate.rs
+++ b/nihav-core/src/compr/deflate.rs
@@ -356,6 +356,14 @@ impl Inflate {
self.full_pos += len;
Ok(())
}
+ ///! Sets custom history for decoding an update for already decoded data.
+ pub fn set_dict(&mut self, dict: &[u8]) {
+ let len = dict.len().min(self.buf.len());
+ let start = dict.len() - len;
+ self.buf[..len].copy_from_slice(&dict[start..]);
+ self.bpos = len;
+ self.full_pos = len;
+ }
///! Reports whether decoder has finished decoding the input.
pub fn is_finished(&self) -> bool {
match self.state {