packkit/codec
Byte-to-byte compression formats and their errors.
Pass a Codec to packkit.compress and packkit.decompress, or list
codecs in a packkit.Recipe to compress a whole archive.
Types
A compression format.
pub type Codec {
Identity
Deflate
Zlib
Gzip
Lz4
Snappy
Bzip2
Lzw
Xz
Zstd
Brotli
}
Constructors
-
IdentityLeaves the bytes unchanged.
-
DeflateRaw DEFLATE (RFC 1951) with no header.
-
Zlibzlib (RFC 1950).
-
Gzipgzip (RFC 1952). Use
packkit/gzipto read or write the header. -
Lz4LZ4 frame format.
-
SnappySnappy framing format.
-
Bzip2 -
LzwUnix
compress(.Z). -
Xz -
ZstdZstandard.
-
BrotliBrotli (RFC 7932).
Errors from compressing and decompressing.
pub type CodecError {
InvalidData(message: String)
LimitExceeded(limit: String, actual: Int)
DictionaryRequired
Unsupported(feature: String)
}
Constructors
-
InvalidData(message: String)The bytes are not a valid stream of the requested format.
-
LimitExceeded(limit: String, actual: Int)The input went over one of the
Limits. -
DictionaryRequiredThe zlib stream was made with a preset dictionary, which packkit does not support.
-
Unsupported(feature: String)The stream is valid but uses a feature packkit does not read.
Values
pub fn error_to_string(error: CodecError) -> String
Describes an error in one line, for logs and command-line output.
Examples
error_to_string(LimitExceeded(limit: "max_input_bytes", actual: 70_000_000))
// -> "codec: limit max_input_bytes exceeded (actual 70000000)"