compressAsync

suspend fun compressAsync(buffer: ReadBuffer, algorithm: CompressionAlgorithm = CompressionAlgorithm.Gzip, level: CompressionLevel = CompressionLevel.Default, factory: BufferFactory = BufferFactory.Default): PlatformBuffer

Compresses data using the specified algorithm. Works on all platforms.

This is a convenience function that handles the streaming API internally. For large data or when you need to process chunks incrementally, use SuspendingStreamingCompressor directly.

Return

The compressed data as a single buffer (position=0, limit=compressed size)

Parameters

buffer

The data to compress (reads from position to limit). Fully consumed after call.

algorithm

The compression algorithm to use

level

The compression level

factory

The buffer factory for the output buffer