Returns the size of the compressed data in bytes.
Returns the size of the decompressed data in bytes, as decoded: a
bigint only when it exceeds Number.MAX_SAFE_INTEGER.
Returns the CRC32 checksum of the decompressed data.
Returns the compression ratio of the data.
The compression ratio is calculated as (compressed size) / (decompressed size), so lower values indicate better compression.
A floating-point value representing the compression ratio.
StaticcodecTagged-CBOR codec. The checksum decodes as a u32 and the size as a
usize, each with dcbor's negative wrap (the reference's
TryFrom<CBOR> for those widths).
StaticfromCreates a new Compressed object with the specified parameters.
This is a low-level constructor that allows direct creation of a
Compressed object without performing compression. It's primarily
intended for deserialization or when working with pre-compressed data.
checksum is a u32 and decompressedSize a usize (a bigint is
accepted above Number.MAX_SAFE_INTEGER), as the reference's fields.
checksum, decompressedSize, compressedData and the optional digest
A new Compressed object
StaticfromCreates a new Compressed object by compressing the provided data.
This is the primary method for creating compressed data. It compresses
with raw DEFLATE at level 6, the reference's compress_to_vec(data, 6),
so the stream is byte-identical to the reference's for the same input.
If the compressed data would be larger than the original data (which can happen with small or already compressed inputs), the original data is stored instead.
The original data to compress
Optionaldigest: Digest
Optional cryptographic digest of the content
A new Compressed object containing the compressed (or original) data
Decompresses and returns the original decompressed data.
This method performs the reverse of the compression process, restoring the original data. It also verifies the integrity of the data using the stored checksum.
The decompressed data
Returns the digest of the compressed data, if available.
The Digest associated with this compressed data, or undefined if none.
Returns whether this compressed data has an associated digest.
Compare with another Compressed: checksum, size, compressed bytes and
the digest, as the reference's derived PartialEq.
Get string representation (the reference's Debug).
The CBOR tags this type decodes from; the first one is used to encode.
Returns the untagged CBOR encoding (as an array).
Format:
[
checksum: uint,
decompressed_size: uint,
compressed_data: bytes,
digest?: Digest // Optional
]
The tagged CBOR form.
As a UR, typed by the first tag's name.
Staticfrom
A compressed binary object with integrity verification.
Uses DEFLATE compression with CRC32 checksums for integrity verification. Optionally includes a cryptographic digest for content identification.