pinch-0.4.3.0: An alternative implementation of Thrift for Haskell.
Copyright(c) Abhinav Gupta 2015
LicenseBSD3
MaintainerAbhinav Gupta <mail@abhinavg.net>
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Pinch.Internal.Builder

Description

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

Documentation

data Builder Source #

A ByteString Builder that knows its final size.

Instances

Instances details
Monoid Builder Source # 
Instance details

Defined in Pinch.Internal.Builder

Semigroup Builder Source # 
Instance details

Defined in Pinch.Internal.Builder

runBuilder :: Builder -> ByteString Source #

Build a ByteString from the given ByteString builder.

append :: Builder -> Builder -> Builder Source #

Append two Builders into one.

int8 :: Int8 -> Builder Source #

Serialize a single signed byte.

word8 :: Word8 -> Builder Source #

Serialize a single unsigned byte.

int16BE :: Int16 -> Builder Source #

Serialize a signed 16-bit integer in big endian format.

int32BE :: Int32 -> Builder Source #

Serialize a signed 32-bit integer in big endian format.

int64BE :: Int64 -> Builder Source #

Serialize a signed 64-bit integer in big endian format.

int64LE :: Int64 -> Builder Source #

Serialize a signed 64-bit integer in little endian format.

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.

getSize :: Builder -> Int Source #

Returns the number of bytes in the builder.