TakCompressor

class TakCompressor(compressionLevel: Int = 19)(source)

Compresses TAKPacketV2 protobuf bytes using zstd with pre-trained dictionaries, and decompresses received wire payloads back to protobuf bytes.

Wire format: zstd-compressed protobuf bytes Flags byte bits 0-5 = dictionary ID, bits 6-7 = reserved. Special value 0xFF = uncompressed raw protobuf.

Multiplatform: the zstd codec itself is reached through the internal ZstdCodec, a single pure-Kotlin implementation used on every target. The wire framing — the 4-byte magic strip/re-prepend, the 0xFF skip-compress path, the dict-ID flags masking, and the MAX_DECOMPRESSED_SIZE guard — all live HERE, above the codec, so every target shares one framing implementation.

Constructors

Link copied to clipboard
constructor(compressionLevel: Int = 19)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class CompressionResult(val protobufSize: Int, val compressedSize: Int, val dictId: Int, val wirePayload: ByteArray)
Link copied to clipboard
data class RemarksFallbackResult(val wirePayload: ByteArray?, val remarksStripped: Boolean)

Functions

Link copied to clipboard

Compress a TakPacketV2Data into a wire payload: zstd-compressed protobuf

Link copied to clipboard

Compress a packet, stripping remarks if the result exceeds maxWireBytes.

Link copied to clipboard

Compress a packet, stripping remarks if needed, and return a detailed result that distinguishes the four possible outcomes:

Link copied to clipboard

Compress and return both the wire payload and intermediate sizes for reporting.

Link copied to clipboard

Decompress a wire payload back to a TakPacketV2Data. Handles both compressed (dict-based) and uncompressed (0xFF) payloads.