use crate::error::{LazippyError, LazippyResult};
pub struct Dict {
buf: Vec<u8>,
pos: usize,
size: usize,
}
impl Dict {
pub fn new(size: usize) -> Self {
Dict {
buf: vec![0u8; size],
pos: 0,
size,
}
}
pub fn copy_match(
&mut self,
_length: u32,
_distance: u32,
_output: &mut Vec<u8>,
) -> LazippyResult<()> {
Err(LazippyError::NotYetImplemented)
}
pub fn push_literal(&mut self, _byte: u8, _output: &mut Vec<u8>) -> LazippyResult<()> {
let _ = (self.buf.as_slice(), self.pos, self.size); Err(LazippyError::NotYetImplemented)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn dict_copy_match_is_stub() {
let mut dict = Dict::new(4096);
let mut out = Vec::new();
let result = dict.copy_match(3, 1, &mut out);
assert!(
matches!(result, Err(LazippyError::NotYetImplemented)),
"expected NotYetImplemented, got {result:?}"
);
}
#[test]
fn dict_push_literal_is_stub() {
let mut dict = Dict::new(4096);
let mut out = Vec::new();
let result = dict.push_literal(b'A', &mut out);
assert!(
matches!(result, Err(LazippyError::NotYetImplemented)),
"expected NotYetImplemented, got {result:?}"
);
}
}