Expand description
Compression and checksum primitives for otf-pixels codecs.
Per ADR-0010 these are written from scratch, and per ADR-0012 they live here rather than inside one codec, because three formats now share them: PNG needs zlib, TIFF needs zlib and LZW, GIF needs LZW.
§Scope
This crate knows about bit streams and byte buffers. It knows nothing about
images, pixels or descriptors, and deliberately does not depend on
otf-pixels-core. That boundary is what lets it be tested directly against
reference implementations — the validation ADR-0010 requires — rather than
only through a codec.
The consequence is a local Error type. Codecs translate it into their
own error at the boundary, which is one small helper per codec and keeps
the stable ErrorCode mapping where it belongs.
§Safety
Every parser here reads attacker-controlled bytes and returns errors rather
than panicking. unsafe_code = "forbid" means the classic decompressor
failure — an out-of-bounds write through a back-reference — is
unrepresentable rather than merely avoided.
Structs§
- Adler32
- An incremental Adler-32, as specified for zlib streams.
- Crc32
- An incremental CRC-32, as specified for PNG chunks.
- Error
- A compression or checksum failure.
- Inflater
- An incremental DEFLATE decompressor.
- Level
- Compression effort, 0 (stored) to 9 (most search).
- LzwDecoder
- Decompresses an LZW stream.
- LzwEncoder
- Compresses to an LZW stream.
- Zlib
Stream - An incremental zlib (RFC 1950) decompressor.
Enums§
- BitOrder
- Which end of a byte codes are packed from.
Functions§
- deflate
- Compress
datainto a raw DEFLATE stream. - inflate_
to - Decompress a raw DEFLATE stream, refusing to exceed
limitoutput bytes. - zlib_
compress - Compress
datainto a zlib stream (RFC 1950). - zlib_
decompress - Decompress a zlib stream (RFC 1950), verifying its Adler-32.
Type Aliases§
- Result
- The result of a compression operation.