nettle-openflow-0.2.0: OpenFlow protocol messages, binary formats, and servers.

Nettle.OpenFlow.StrictPut

Description

This module provides a monad for serializing data into byte strings. It provides mostly the same interface that Data.Binary.Put does. However, the implementation is different. It allows for the data to be serialized into an existing array of Word8 values. This differs from the Data.Binary.Put data type, which allocates a Word8 array every time a value is serialized. This module's implementation is useful if you want to reuse the Word8 array for many serializations. In the case of an OpenFlow server, we can reuse a buffer to send messages, since we have no use for the the Word8 array, except to pass it to an IO procedure to write the data to a socket or file.

Synopsis

Documentation

data PutM a Source

Instances

runPut :: Ptr Word8 -> Put -> IO IntSource

Runs the Put writer with write position given by the first pointer argument. Returns the number of words written.

runPutToByteString :: Int -> Put -> ByteStringSource

Allocates a new byte string, and runs the Put writer with that byte string. The first argument is an upper bound on the size of the array needed to do the serialization.

putWord32be :: Word32 -> PutSource

Write a Word32 in big endian format

putWord64be :: Word64 -> PutSource

Write a Word64 in big endian format