Relative Content

Tag Archive for rustcompressionhuffman-code

How to write already generated Huffman Codes to file in Rust

I am trying to implement Huffman encoding to compress files (for learning purpouses). I can generate Huffman codes for a given message and use that to build a binary string containing the compressed message. However I am stumped on how to save this “compressed” data. I want to have this data be as compact as possible (since its compression) but I am not sure if serde is the right approach. Even if it is what should I serialize as? (For example, something like Json would probably be bad for my use case since I do not care about human readability). Maybe I should just write the bytes to a file, but then I do not know how to include the lookup dictionary.