Copyright | (c) Abhinav Gupta 2015 |
---|---|
License | BSD3 |
Maintainer | Abhinav Gupta <mail@abhinavg.net> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module implements a ByteString builder very similar to
Builder
except that it keeps track of its final serialized
length. This allows it to allocate the target ByteString in one malloc
and
simply write the bytes to it.
Synopsis
- data Builder
- runBuilder :: Builder -> ByteString
- append :: Builder -> Builder -> Builder
- int8 :: Int8 -> Builder
- word8 :: Word8 -> Builder
- int16BE :: Int16 -> Builder
- int32BE :: Int32 -> Builder
- int64BE :: Int64 -> Builder
- int64LE :: Int64 -> Builder
- doubleBE :: Double -> Builder
- doubleLE :: Double -> Builder
- byteString :: ByteString -> Builder
Documentation
A ByteString Builder that knows its final size.
runBuilder :: Builder -> ByteString Source #
Build a ByteString from the given ByteString builder.
doubleBE :: Double -> Builder Source #
Serialize a signed 64-bit floating point number in big endian format.
doubleLE :: Double -> Builder Source #
Serialize a signed 64-bit floating point number in little endian format.
byteString :: ByteString -> Builder Source #
Inlcude the given ByteString as-is in the builder.
Note that because this operation is applied lazily, we will maintain a reference to the ByteString until the builder is executed.