pub struct Huffman { /* private fields */ }Expand description
Decompresses chat messages.
Examples
use rscache::util::Huffman;
let huffman_tbl = cache.huffman_table()?;
let huffman = Huffman::new(&huffman_tbl);
let compressed_msg = &[174, 128, 35, 32, 208, 96];
let decompressed_len = 8; // client will include this in the chat packet.
let decompressed_msg = huffman.decompress(compressed_msg, decompressed_len);
if let Ok(msg) = String::from_utf8(decompressed_msg) {
assert_eq!(msg, "rs-cache");
}Implementations
Initializes the Huffman struct with the given sizes.
The sizes can be found in the cache.
Call the huffman_table() function to get the huffman table which
contains the sizes needed to initialize this struct.
Decompresses the given buffer.
The buffer is normally an encoded chat message which will be decoded into the original message. This helps limit chat packet sizes.
Panics
Panics if the decompressed length == 0
Trait Implementations
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Huffman
impl UnwindSafe for Huffman
Blanket Implementations
Mutably borrows from an owned value. Read more