StaticnewCreates 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.
CRC32 checksum of the decompressed data
Size of the original decompressed data in bytes
The compressed data bytes
Optionaldigest: DigestOptional cryptographic digest of the content
A new Compressed object
StaticfromCreates a new Compressed object by compressing the provided data.
This is the primary method for creating compressed data. It automatically handles compression using the DEFLATE algorithm with compression level 6.
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: DigestOptional 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 size of the compressed data in bytes.
Returns the size of the decompressed data in bytes.
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.
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.
Get string representation.
Returns the CBOR tags associated with Compressed.
Returns the untagged CBOR encoding (as an array).
Format:
[
checksum: uint,
decompressed_size: uint,
compressed_data: bytes,
digest?: Digest // Optional
]
Returns the tagged CBOR encoding.
Returns the tagged value in CBOR binary representation.
StaticfromStaticfromStaticfromStatic method to decode from untagged CBOR binary data.
A compressed binary object with integrity verification.
Uses DEFLATE compression with CRC32 checksums for integrity verification. Optionally includes a cryptographic digest for content identification.