-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose crc32 #44
Comments
That function is mainly there for the C api (which is the root folder) that mimicks the miniz C api. It's just a wrapper over the relevant functions in the crc library, so one may as well use that directly. the miniz_oxide subfolder is the actual miniz_oxide library. The C api is mainly used as an for an easy swap-in back-end for the flate2 crate. I wouldn't really recommend using it in a rust project otherwise as it's full of unsafe c exported functions. CRC is only used for the gzip metadata, which tacks on to the start and end of the deflate-compressed stream. It's not used in the core miniz_oxide crate at all, that's really up to the front-end. Generally I would suggest using flate2 with the rust back-end, which uses this library, as that has a nice streaming front-end. Going low level is only really needed if you need some special tight control of parameters like in the oxipng PNG optimizer. As for the streaming decompression, still haven't gotten around to documenting it well. There is a brief overview in the issue and the linked project. I'll open a separate issue for that. |
The distinction is between the C API (root folder) and the underlying miniz_oxide decompression library. The The C API was mainly to ease creating a drop-in replacement for miniz/zlib in the flate2 crate which provides an easy to use front-end for decompression, including streaming. And yeah, still need to write some documentation showing the use of the core decompression function. There is some info in that issue, and in the linked repository in the meantime. Granted, I would recommend using the reader/writers in flate2 unless you have some special low-level needs. |
Thanks for pointing out the linked project! I used miniz in some C++ projects and like that it is so small. I'm still considering flate2, but don't see a compelling reason to use it at the moment. Regarding crc32: adler is also exposed, so why stop there? If crc32 is included for the benefit of flate2, why shouldn't other users of the library have easy access, as they are also "paying" for the additional dependency? I think it would be cool if miniz_oxide could be both the backend for flate2, but at the same time a maximally compact deflate implementation, in the spirit of miniz. |
miniz_oxide uses the crc32fast crate since e8d2a58, so you will get the exact same thing (and exact same dependency list) if you simply use that crate directly. |
Closing this. As stated, one may as well use the library used, and it's only used in the C api anyhow.
Yeah only the miniz_oxide subfolder is needed. The rest is the C API analogue. Though, if one uses that one would need to handle the gzip header manually, e.g with the gzip-header crate. |
Until miniz_oxide switches to another crate.
Or just do it manually. |
Exposing
mz_crc32_oxide()
could be useful for writing a PNG encoder/decoder that uses miniz_oxide for zlib compression anyway.I can see that it is part of miniz_oxide/src/lib.rs, but not of miniz_oxide/miniz_oxide/src/lib.rs. But I don't understand what the difference is, only that I could not access mz_crc32_oxide().
On a related note, how can you access the streaming decompression that is discussed in issue 24?
The text was updated successfully, but these errors were encountered: