ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Zlib

Description

Owned zlib streams over the existing streaming-commons ABI. A caller opens a stream inside its own bracket, advances it in bounded native calls, and releases it there, so the native state never waits for a collector. Each call is an unsafe foreign call, which holds its capability and blocks collection while it runs, so every step is bounded to keep that pause short.

Synopsis

Opening and releasing a stream

data ZlibFault Source #

A stream the native library could not allocate, or one that reported state no valid stream reaches.

openStream :: (ZStream' -> IO CInt) -> IO ZStream' Source #

Allocate a stream and run its initialiser. A failed initialiser frees the allocation before the fault escapes.

initialiseInflate :: ZStream' -> CInt -> IO CInt Source #

Initialise an inflater with the given window bits.

initialiseDeflate :: ZStream' -> CInt -> CInt -> CInt -> CInt -> IO CInt Source #

Initialise a deflater. The arguments after the stream are level, window bits, memory level, and strategy.

releaseInflate :: ZStream' -> IO () Source #

End an inflater and free its stream.

releaseDeflate :: ZStream' -> IO () Source #

End a deflater and free its stream.

One bounded native call

advanceStream :: (ZStream' -> IO CInt) -> ZStream' -> ByteString -> Ptr Word8 -> Int -> IO (CInt, Int, Int) Source #

One call over at most room output bytes: the status, the input bytes consumed, and the output bytes written.