flatbuffers-0.1.0.0: Haskell implementation of the FlatBuffers protocol.

Safe HaskellNone
LanguageHaskell2010

FlatBuffers.Internal.Read

Synopsis

Documentation

newtype VOffset Source #

Constructors

VOffset 

Fields

Instances
Enum VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Eq VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Methods

(==) :: VOffset -> VOffset -> Bool #

(/=) :: VOffset -> VOffset -> Bool #

Integral VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Num VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Ord VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Real VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Show VOffset Source # 
Instance details

Defined in FlatBuffers.Internal.Read

newtype OffsetFromRoot Source #

Constructors

OffsetFromRoot Int32 
Instances
Enum OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Eq OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Integral OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Num OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Ord OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Real OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Show OffsetFromRoot Source # 
Instance details

Defined in FlatBuffers.Internal.Read

data Table a Source #

A table that is being read from a flatbuffer.

Constructors

Table 
Instances
VectorElement (Table a) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector (Table a) :: Type Source #

HasPosition (Vector (Table a)) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Methods

getPosition :: Vector (Table a) -> Position Source #

move :: Integral i => Vector (Table a) -> i -> Vector (Table a) Source #

newtype Vector (Table a) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

newtype Struct a Source #

A struct that is being read from a flatbuffer.

Constructors

Struct 

Fields

data Union a Source #

A union that is being read from a flatbuffer.

Constructors

Union !a 
UnionNone 
UnionUnknown !Word8 

data PositionInfo Source #

Current position in the buffer

Constructors

PositionInfo 

Fields

class HasPosition a where Source #

Methods

getPosition :: a -> Position Source #

move :: Integral i => a -> i -> a Source #

Instances
HasPosition ByteString Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition PositionInfo Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Bool) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Double) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Float) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Int8) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Int16) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Int32) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Int64) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Word8) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Word16) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Word32) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector Word64) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

HasPosition (Vector (Table a)) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Methods

getPosition :: Vector (Table a) -> Position Source #

move :: Integral i => Vector (Table a) -> i -> Vector (Table a) Source #

decode :: ByteString -> Either ReadError (Table a) Source #

Deserializes a flatbuffer from a lazy ByteString.

checkFileIdentifier :: forall a. HasFileIdentifier a => ByteString -> Bool Source #

Checks if a buffer contains the file identifier for a root table a, to see if it's safe to decode it to a Table. It should be used in conjunction with -XTypeApplications.

{-# LANGUAGE TypeApplications #-}

if checkFileIdentifier @Monster bs
  then decode @Monster bs
  else return someMonster

moveToElem :: HasPosition pos => pos -> Int32 -> Int32 -> pos Source #

class VectorElement a where Source #

Minimal complete definition

length, unsafeIndex, toList

Associated Types

data Vector a Source #

A vector that is being read from a flatbuffer.

Methods

length :: Vector a -> Either ReadError Int32 Source #

Returns the size of the vector.

index :: Vector a -> Int32 -> Either ReadError a Source #

Returns the item at the given index. If the given index is negative or too large, an error is thrown.

unsafeIndex :: Vector a -> Int32 -> Either ReadError a Source #

Returns the item at the given index without performing the bounds check.

Given an invalid index, unsafeIndex will likely read garbage data or return a ReadError. In the case of Vector Word8, using a negative index carries the same risks as unsafeIndex (i.e. reading from outside the buffer's boundaries).

toList :: Vector a -> Either ReadError [a] Source #

Converts the vector to a list.

Instances
VectorElement Bool Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Bool :: Type Source #

VectorElement Double Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Double :: Type Source #

VectorElement Float Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Float :: Type Source #

VectorElement Int8 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Int8 :: Type Source #

VectorElement Int16 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Int16 :: Type Source #

VectorElement Int32 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Int32 :: Type Source #

VectorElement Int64 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Int64 :: Type Source #

VectorElement Word8 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Word8 :: Type Source #

VectorElement Word16 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Word16 :: Type Source #

VectorElement Word32 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Word32 :: Type Source #

VectorElement Word64 Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Word64 :: Type Source #

VectorElement Text Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector Text :: Type Source #

VectorElement (Union a) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector (Union a) :: Type Source #

VectorElement (Struct a) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector (Struct a) :: Type Source #

VectorElement (Table a) Source # 
Instance details

Defined in FlatBuffers.Internal.Read

Associated Types

data Vector (Table a) :: Type Source #

readText :: HasPosition a => a -> Either ReadError Text Source #

Follow a pointer to the position of a string and read it.

readText' :: Get (Either ReadError Text) Source #

Read a string from the current buffer position.

readTable :: PositionInfo -> Either ReadError (Table t) Source #

Follow a pointer to the position of a table and read it.

readTable' :: PositionInfo -> Either ReadError (Table t) Source #

Read a table from the current buffer position.

byteStringSafeIndex :: ByteString -> Int32 -> Either ReadError Word8 Source #

Safer version of index that doesn't throw when index is too large. Assumes i > 0.