|Copyright||Lennart Kolmodin, Ross Paterson, Galois Inc. 2009|
|License||BSD3-style (see LICENSE)|
|Maintainer||Trevor Elliott <email@example.com>|
Efficient construction of lazy bytestrings.
- data Builder
- toByteString :: Builder -> ByteString
- toLazyByteString :: Builder -> ByteString
- empty :: Builder
- singleton :: Word8 -> Builder
- append :: Builder -> Builder -> Builder
- fromByteString :: ByteString -> Builder
- fromLazyByteString :: ByteString -> Builder
- flush :: Builder
- putWord16be :: Word16 -> Builder
- putWord32be :: Word32 -> Builder
- putWord64be :: Word64 -> Builder
- putWord16le :: Word16 -> Builder
- putWord32le :: Word32 -> Builder
- putWord64le :: Word64 -> Builder
- putWordhost :: Word -> Builder
- putWord16host :: Word16 -> Builder
- putWord32host :: Word32 -> Builder
- putWord64host :: Word64 -> Builder
The Builder type
Builder is an efficient way to build lazy
There are several functions for constructing
Builders, but only one
to inspect them: to extract any data, you have to turn them into lazy
Builder constructs a lazy
Bytestring by filling byte
arrays piece by piece. As each buffer is filled, it is 'popped'
off, to become a new chunk of the resulting lazy
All this is hidden from the user of the
Flushing the buffer state
Host-endian, unaligned writes
O(1). A Builder taking a single native machine word. The word is written in host order, host endian form, for the machine you're on. On a 64 bit machine the Word is an 8 byte value, on a 32 bit machine, 4 bytes. Values written this way are not portable to different endian or word sized machines, without conversion.
Write a Word16 in native host order and host endianness. 2 bytes will be written, unaligned.
Write a Word32 in native host order and host endianness. 4 bytes will be written, unaligned.