Safe Haskell | None |
---|---|
Language | Haskell98 |
Provides toByteStringIO*
like Blaze.ByteString.Builders, for Data.ByteString.Builder.
Since 0.1.9
- toByteStringIO :: (ByteString -> IO ()) -> Builder -> IO ()
- toByteStringIOWith :: Int -> (ByteString -> IO ()) -> Builder -> IO ()
- toByteStringIOWithBuffer :: Int -> (ByteString -> IO ()) -> Builder -> ForeignPtr Word8 -> IO ()
Documentation
toByteStringIO :: (ByteString -> IO ()) -> Builder -> IO () Source
Run the builder with a defaultChunkSize
d buffer and execute the given
IO
action whenever the buffer is full or gets flushed.
toByteStringIO
=toByteStringIOWith
defaultChunkSize
Since 0.1.9
:: Int | Buffer size (upper bounds
the number of bytes forced
per call to the |
-> (ByteString -> IO ()) |
|
-> Builder |
|
-> IO () |
toByteStringIOWith bufSize io b
runs the builder b
with a buffer of
at least the size bufSize
and executes the IO
action io
whenever the
buffer is full.
Compared to toLazyByteStringWith
this function requires less allocation,
as the output buffer is only allocated once at the start of the
serialization and whenever something bigger than the current buffer size has
to be copied into the buffer, which should happen very seldomly for the
default buffer size of 32kb. Hence, the pressure on the garbage collector is
reduced, which can be an advantage when building long sequences of bytes.
Since 0.1.9
toByteStringIOWithBuffer :: Int -> (ByteString -> IO ()) -> Builder -> ForeignPtr Word8 -> IO () Source
Use a pre-existing buffer to toByteStringIOWith
.
Since 0.1.9