packkit
Facade for the packkit package. This module wires the codec,
archive, and recipe primitives so callers can read, write, pack,
and unpack data without selecting the underlying engine by hand.
Types
pub type Archive =
archive.Archive
pub type ArchiveError =
error.ArchiveError
pub type ArchiveFormat =
archive.ArchiveFormat
pub type Codec =
codec.Codec
pub type CodecError =
error.CodecError
pub type DetectError =
error.DetectError
pub type Detected =
detect.Detected
pub type Limits =
limit.Limits
pub type Recipe =
recipe.Recipe
Values
pub fn compress(
bytes bytes: BitArray,
with codec_value: codec.Codec,
) -> Result(BitArray, error.CodecError)
Compress bytes with codec. The codec’s optional level and
preset dictionary are honoured where the family supports them; if
the family cannot honour an option a typed CodecOptionUnsupported
error is returned instead of silently dropping the request.
pub fn decompress(
bytes bytes: BitArray,
with codec_value: codec.Codec,
) -> Result(BitArray, error.CodecError)
Decompress bytes with codec using the default limits. Honours
the codec’s optional preset dictionary (currently only zlib) and
otherwise rejects dictionary use with a typed error.
pub fn decompress_with_limits(
bytes bytes: BitArray,
with codec_value: codec.Codec,
limits limits: limit.Limits,
) -> Result(BitArray, error.CodecError)
Decompress bytes with codec, threading the supplied Limits
value through to the underlying codec’s decode_with_limits
entrypoint. Codecs without an explicit limits hook receive their
own family-specific defaults; today every byte-to-byte codec we
support honours Limits.
pub fn detect_bytes(
bytes: BitArray,
) -> Result(detect.Detected, error.DetectError)
Detect from byte signatures.
pub fn detect_filename(
path: String,
) -> Result(detect.Detected, error.DetectError)
Detect from a filename or path suffix.
pub fn detect_path_or_bytes(
path path: String,
bytes bytes: BitArray,
) -> Result(detect.Detected, error.DetectError)
Detect via filename first, then fall back to magic-byte detection
on the supplied content. Re-exports
packkit/detect.from_path_or_bytes from the top-level facade so
most CLI integrations only need to import packkit.
pub fn pack(
archive_value archive_value: archive.Archive,
using recipe_value: recipe.Recipe,
) -> Result(BitArray, error.ArchiveError)
Pack an archive with the codec chain described by recipe.
pub fn read(
bytes bytes: BitArray,
format format: archive.ArchiveFormat,
) -> Result(archive.Archive, error.ArchiveError)
Read an archive from bytes interpreted as format using the
default resource limits.
pub fn read_with_limits(
bytes bytes: BitArray,
format format: archive.ArchiveFormat,
limits limits: limit.Limits,
) -> Result(archive.Archive, error.ArchiveError)
Read an archive while threading the supplied Limits through to
the underlying archive decoder. Each family enforces the subset of
limits that applies to it (input size, member count, name length,
entry depth).
pub fn unpack(
bytes bytes: BitArray,
using recipe_value: recipe.Recipe,
) -> Result(archive.Archive, error.ArchiveError)
Unpack a byte stream produced by recipe using the default
resource limits.
pub fn unpack_with_limits(
bytes bytes: BitArray,
using recipe_value: recipe.Recipe,
limits limits: limit.Limits,
) -> Result(archive.Archive, error.ArchiveError)
Unpack a byte stream produced by recipe, threading the supplied
Limits through both the codec chain and the underlying archive
decoder.
pub fn write(
archive_value archive_value: archive.Archive,
format format: archive.ArchiveFormat,
) -> Result(BitArray, error.ArchiveError)
Serialise an archive to bytes using format. The supplied
format must match the format tag the Archive was constructed
with — Archive is bound to one format at construction time, and
pretending it is a different format would silently corrupt the
output. Mismatches surface as ArchiveFormatMismatch.