createCompressor : ZlibCompressionLevel -> Wrapper -> IO (Either (List ZlibError) Compressor) Allocate and initialize a zlib compression stream.
If initialization fails, the native stream allocation is released before
returning the error. A successful result therefore represents a fully
initialized stream that must later be destroyed with `destroyCompressor`.
Totality: total
Visibility: exportdestroyCompressor : Compressor -> IO () Finalize and release a zlib compression stream.
`deflateEnd` releases resources owned internally by zlib, after which
`prim__freeStream` releases the opaque stream allocation owned by the
C shim.
This function is intended primarily as the release action used by
`withCompressor`.
Totality: total
Visibility: exportcreateDecompressor : Wrapper -> IO (Either (List ZlibError) Decompressor) Allocate and initialize a zlib decompression stream.
If initialization fails, the native stream allocation is released before
returning the error. A successful result therefore represents a fully
initialized stream that must later be destroyed with
`destroyDecompressor`.
Totality: total
Visibility: exportdestroyDecompressor : Decompressor -> IO () Finalize and release a zlib decompression stream.
`inflateEnd` releases resources owned internally by zlib, after which
`prim__freeStream` releases the opaque stream allocation owned by the
C shim.
This function is intended primarily as the release action used by
`withDecompressor`.
Totality: total
Visibility: exportwithCompressor : ZlibCompressionLevel -> Wrapper -> (Compressor -> IO (Either (List ZlibError) a)) -> IO (Either (List ZlibError) a) Execute an action with a freshly initialized zlib compression stream.
The compressor is finalized and released regardless of how the protected
action exits. Failure to initialize the compressor is returned without
executing the supplied action.
Totality: total
Visibility: exportwithDecompressor : Wrapper -> (Decompressor -> IO (Either (List ZlibError) a)) -> IO (Either (List ZlibError) a) Execute an action with a freshly initialized zlib decompression stream.
The decompressor is finalized and released regardless of how the protected
action exits. Failure to initialize the decompressor is returned without
executing the supplied action.
Totality: total
Visibility: exportdeflateBound : Compressor -> Nat -> IO (Either (List ZlibError) Nat) Compute an upper bound on the number of bytes required to compress an
input of the given size with an initialized compressor.
The returned capacity is sufficient for single-pass compression when the
complete input is supplied to `deflateBuffer` and the flush mode is
`Finish`. In that case, zlib guarantees that an output buffer of at least
this size is sufficient for `deflate` to complete with `Z_STREAM_END`.
This helper additionally enforces the size limits of the raw buffer bridge:
both the input length and resulting output capacity must fit in the
`uInt`-sized lengths used by zlib's `avail_in` and `avail_out` fields.
Returns an error when the requested input or resulting bound cannot be
represented safely by the one-shot buffer API.
Totality: total
Visibility: exportdeflateBuffer : Compressor -> (inputoffset : Nat) -> (inputlength : Nat) -> IBuffer n -> {auto 0 _ : LTE (inputoffset + inputlength) n} -> (outputoffset : Nat) -> (outputlength : Nat) -> IOBuffer m -> {auto 0 _ : LTE (outputoffset + outputlength) m} -> FlushMode -> IO (Either (List ZlibError) BufferResult) Compress a region of an immutable input buffer into a region of a mutable
output buffer.
Neither buffer is copied before crossing the FFI boundary. On the Chez
backend, their underlying bytevectors are borrowed as `u8*` values for
the duration of the atomic C call.
The C shim guarantees that the borrowed pointers are removed from the
underlying `z_stream` before returning.
The returned `BufferResult` reports how many input bytes were consumed
and how many output bytes were produced.
Totality: total
Visibility: exportinflateBuffer : Decompressor -> (inputoffset : Nat) -> (inputlength : Nat) -> IBuffer n -> {auto 0 _ : LTE (inputoffset + inputlength) n} -> (outputoffset : Nat) -> (outputlength : Nat) -> IOBuffer m -> {auto 0 _ : LTE (outputoffset + outputlength) m} -> FlushMode -> IO (Either (List ZlibError) BufferResult) Decompress a region of an immutable input buffer into a region of a mutable
output buffer.
Neither buffer is copied before crossing the FFI boundary. On the Chez
backend, their underlying bytevectors are borrowed as `u8*` values for
the duration of the atomic C call.
The C shim guarantees that the borrowed pointers are removed from the
underlying `z_stream` before returning.
`Z_OK` indicates that decompression can continue. `Z_STREAM_END` indicates
that the complete compressed stream has been decoded. Both are represented
as successful `BufferResult` values; the caller can use the stream-oriented
operation when it needs to distinguish them.
Totality: total
Visibility: export