This library does not currently handle compression

https://crates.io/crates/tar
I am unsure as to what are the limitation of this library. That is, I do understand when they say that this lib doesn't currently handle the compression but in the examples, they do provide code snippet which clearly shows that they using this lib to write a file. So, I assume write!=compress, but in that case, what does write mean?

Any explanations appreciated
Thank you

The .tar file format allows you to store several files in a single file, similar to a zip archive, but unlike zip archives, a .tar file is not compressed to make it smaller.

1 Like

The tar format doesn’t compress data. “Compression” here refers to making files smaller (less disk usage) without losing informartion by using stuff like e.g. repeated patterns or the fact that a text file doesn’t use a lot of non-alphabetic characters, etc.. Especially Linux/Unix users will often encounter .tar.gz file endings (or similar). The gz ending comes from gzip compression, basically a tool that can compress single files, so you’d turn something like foo.txt into foo.txt.gz. The tar format on the other hand only has the purpose of combining multiple files (e.g. a directory or a directory structure) into a single file; that’s why these two formats compose pretty well. People turn a directory foo into a foo.tar archive and then compress this single file into foo.tar.gz.

The tar library you linked says it only handles the tar part of this practice, so no compression. (Also, of course, you don’t always need to do the compression step. Especially with small files nowadays compression might be pretty redundant, tar alone can help out for things like – for example – sending a directory over email, etc.)

For comparison, other archive formats like e.g. zip do both compression and saving a directory structure in a single file.

2 Likes

Thank you guys.