Skip to content

Compressor

A stream compressing bytes written to it into a sink.

Returned by compress. Handing it to a function that takes an Io lets that function write through it, and the stream stays open.

Inherits from: io.Io

Fields

format @ Format [get]

The format being written.

Methods

close()

Finishes the compressed stream, then closes the sink if it was opened from a path, or flushes it otherwise. Closing again does nothing.

The output is incomplete until the stream is closed.

write *data -> Int

Compresses and writes data, given in pieces.

Raises StateError when the stream is closed.

Parameters

NameTypeDescription
*data (Bin | Str) Data to write.

Returns

The number of bytes written, which is all of them.