pub struct HuffmanCompressor;Expand description
Simplified Huffman encoding
Implementations§
Source§impl HuffmanCompressor
impl HuffmanCompressor
Sourcepub fn compress(data: &[u8]) -> Vec<u8> ⓘ
pub fn compress(data: &[u8]) -> Vec<u8> ⓘ
Compresses data using Huffman encoding.
Format:
- 2 bytes: number of distinct symbols (u16 LE)
- For each symbol: 1 byte symbol value + 4 bytes frequency (u32 LE)
- 8 bytes: original data length (u64 LE)
- Remaining bytes: Huffman-encoded bit stream (MSB first within each byte)
Sourcepub fn decompress(compressed: &[u8]) -> WasmResult<Vec<u8>>
pub fn decompress(compressed: &[u8]) -> WasmResult<Vec<u8>>
Decompresses Huffman-encoded data produced by HuffmanCompressor::compress.
Reads the frequency table stored in the header to reconstruct the identical Huffman tree, then decodes the bit stream up to the stored original length.
Auto Trait Implementations§
impl Freeze for HuffmanCompressor
impl RefUnwindSafe for HuffmanCompressor
impl Send for HuffmanCompressor
impl Sync for HuffmanCompressor
impl Unpin for HuffmanCompressor
impl UnsafeUnpin for HuffmanCompressor
impl UnwindSafe for HuffmanCompressor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more