diff options
author | gennyble <gen@nyble.dev> | 2023-09-10 02:44:01 -0500 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2023-09-10 02:44:01 -0500 |
commit | a962ba9c853a797e9a41b2830ec0181b167d8cd9 (patch) | |
tree | 7de53dfcaf87c5d4b43f2e8b38161eb193c136ad /unpacker/src/lib.rs | |
parent | 70187683361d97a8b5a251567323c323c90302f2 (diff) | |
download | lri-rs-a962ba9c853a797e9a41b2830ec0181b167d8cd9.tar.gz lri-rs-a962ba9c853a797e9a41b2830ec0181b167d8cd9.zip |
reorg
Diffstat (limited to 'unpacker/src/lib.rs')
-rw-r--r-- | unpacker/src/lib.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/unpacker/src/lib.rs b/unpacker/src/lib.rs deleted file mode 100644 index f649581..0000000 --- a/unpacker/src/lib.rs +++ /dev/null @@ -1,44 +0,0 @@ -#[derive(Debug)] -pub struct Unpacker { - pub out: Vec<u8>, - pub work: u16, - pub work_idx: usize, -} - -impl Unpacker { - pub fn new() -> Self { - Self { - out: vec![], - work: 0, - work_idx: 0, - } - } - - pub fn push(&mut self, byte: u8) { - self.work = self.work << 8; - self.work |= byte as u16; - self.work_idx += 8; - - //println!("[{work_idx}]"); - - if self.work_idx >= 10 { - let to_front = self.work_idx - 10; - let fronted = self.work >> to_front; - let masked = fronted & 0b000_000_111_11_111_11; - - let fixwork = fronted << to_front; - - self.out.extend(masked.to_le_bytes()); - self.work_idx -= 10; - self.work ^= fixwork; - } - } - - pub fn finish(&mut self) { - if self.work_idx > 0 { - let remain = 10 - self.work_idx; - let out = self.work << remain; - self.out.extend(out.to_le_bytes()) - } - } -} |