Function huff_tree_tap::huffman_encode
source · pub fn huffman_encode(data: &Vec<u8>) -> HuffmanData
👎Deprecated since 0.0.4: please use
huff_tree_tap::HuffmanData::new()
insteadExpand description
Huffman encodes a Vec<u8>
returning a HuffmanData
struct
Arguments
data
- A reference toVec<u8>
containing the data you want to encode
Examples
extern crate huff_tree_tap;
use huff_tree_tap::*;
use std::collections::HashMap;
let data: Vec<u8> = "this is a test string!".to_string().into_bytes();
let huffman_data: HuffmanData = huffman_encode(&data);
let decoded_data: Vec<u8> = huffman_decode(&huffman_data);
assert_eq!(decoded_data,data);