flatbuffers-0.1.0.0: Haskell implementation of the FlatBuffers protocol.

Safe HaskellNone
LanguageHaskell2010

FlatBuffers.Internal.Write

Synopsis

Documentation

type Position = Int32 Source #

The position of something in a buffer, expressed as the number of bytes counting from the end.

newtype WriteStruct a Source #

A struct to be written to a flatbuffer.

Constructors

WriteStruct 

Fields

newtype WriteTable a Source #

A table to be written to a flatbuffer.

data WriteUnion a Source #

A union to be written to a flatbuffer.

Constructors

Some !Word8 !(State FBState Position) 
None 

encode :: WriteTable a -> ByteString Source #

Serializes a flatbuffer table as a lazy ByteString.

encodeWithFileIdentifier :: forall a. HasFileIdentifier a => WriteTable a -> ByteString Source #

Serializes a flatbuffer table as a lazy ByteString and adds a File Identifier.

write :: Int32 -> Builder -> FBState -> FBState Source #

Writes something (unaligned) to the buffer.

writeInt32 :: Int32 -> FBState -> FBState Source #

Writes a 32-bit int (unaligned) to the buffer.

none :: WriteUnion a Source #

Constructs a missing union table field / vector element.

class WriteVectorElement a where Source #

Associated Types

data WriteVector a Source #

A vector to be written to a flatbuffer.

Methods

fromFoldable Source #

Arguments

:: Foldable f 
=> Int32

n: the number of elements in xs

-> f a

xs: a collection

-> WriteVector a 

Constructs a flatbuffers vector.

If n is larger than the length of xs, this will result in a malformed buffer. If n is smaller than the length of xs, all elements of xs will still be written to the buffer, but the client will only be able to read the first n elements.

Note: fromFoldable asks for the collection's length to be passed in as an argument rather than use Foldable.length because:

  1. Foldable.length is often O(n), and in some use cases there may be a better way to know the collection's length ahead of time.
  2. Calling Foldable.length inside fromFoldable can inhibit some fusions which would otherwise be possible.
Instances
WriteVectorElement Bool Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Bool :: Type Source #

WriteVectorElement Double Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Double :: Type Source #

WriteVectorElement Float Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Float :: Type Source #

WriteVectorElement Int8 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Int8 :: Type Source #

WriteVectorElement Int16 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Int16 :: Type Source #

WriteVectorElement Int32 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Int32 :: Type Source #

WriteVectorElement Int64 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Int64 :: Type Source #

WriteVectorElement Word8 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Word8 :: Type Source #

WriteVectorElement Word16 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Word16 :: Type Source #

WriteVectorElement Word32 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Word32 :: Type Source #

WriteVectorElement Word64 Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Word64 :: Type Source #

WriteVectorElement Text Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector Text :: Type Source #

WriteVectorElement (WriteUnion a) Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector (WriteUnion a) :: Type Source #

WriteVectorElement (WriteTable a) Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector (WriteTable a) :: Type Source #

IsStruct a => WriteVectorElement (WriteStruct a) Source # 
Instance details

Defined in FlatBuffers.Internal.Write

Associated Types

data WriteVector (WriteStruct a) :: Type Source #

fromFoldable' :: WriteVectorElement a => Foldable f => f a -> WriteVector a Source #

Convenience function, equivalent to:

fromFoldable' xs = fromFoldable (fromIntegral (Foldable.length xs)) xs

In some cases it may be slower than using fromFoldable directly.

fromList :: WriteVectorElement a => Int32 -> [a] -> WriteVector a Source #

fromFoldable specialized to list

fromList' :: WriteVectorElement a => [a] -> WriteVector a Source #

fromFoldable' specialized to list

singleton :: WriteVectorElement a => a -> WriteVector a Source #

Creates a flatbuffers vector with a single element

empty :: WriteVectorElement a => WriteVector a Source #

Creates an empty flatbuffers vector

data TextInfo Source #

Constructors

TextInfo 

data OffsetInfo Source #

Constructors

OffsetInfo 

Fields

data TableInfo Source #

Constructors

TableInfo 

data Vecs a Source #

Constructors

Vecs ![Word8] ![Maybe (State FBState Position)] 

calcPadding Source #

Arguments

:: Alignment

n

-> Int32

additionalBytes

-> BufferSize 
-> Int32 

Calculate how much 0-padding is needed so that, after writing additionalBytes, the buffer becomes aligned to n bytes.

alignTo Source #

Arguments

:: Alignment

n

-> Int32

additionalBytes

-> FBState 
-> FBState 

Add enough 0-padding so that the buffer becomes aligned to n after writing additionalBytes.