protobuf-simple-0.1.0.2: Simple Protocol Buffers library (proto2)

Copyright(c) 2015-2016 Martijn Rijkeboer <mrr@sru-systems.com>
LicenseMIT
MaintainerMartijn Rijkeboer <mrr@sru-systems.com>
Safe HaskellNone
LanguageHaskell2010

Data.ProtoBufInt

Description

Internal functions used by the generated types.

Synopsis

Documentation

class Default a where Source #

Typeclass to handle default values.

Minimal complete definition

defaultVal

Methods

defaultVal :: a Source #

The default value for the field.

fromFieldNumber :: FieldNumber -> Word32 Source #

Convert a FieldNumber into a Word32.

toFieldNumber :: Word32 -> Either String FieldNumber Source #

Convert a Word32 into a FieldNumber or an error.

class Mergeable a where Source #

Typeclass to handle merging of values.

Methods

merge :: a -> a -> a Source #

Merge two values.

class Required a where Source #

Typeclass to retrieve required WireTags.

Minimal complete definition

reqTags

Methods

reqTags :: a -> Set WireTag Source #

The required WireTags for the data type.

class WireEnum a where Source #

Typeclass to handle encoding en decoding of enums.

Minimal complete definition

intToEnum, enumToInt

Methods

intToEnum :: Int32 -> a Source #

Convert an Int32 to an enum value.

enumToInt :: a -> Int32 Source #

Convert a enum value to an Int32.

class Default a where Source #

Typeclass to handle default values.

Minimal complete definition

defaultVal

Methods

defaultVal :: a Source #

The default value for the field.

fromFieldNumber :: FieldNumber -> Word32 Source #

Convert a FieldNumber into a Word32.

toFieldNumber :: Word32 -> Either String FieldNumber Source #

Convert a Word32 into a FieldNumber or an error.

class Mergeable a where Source #

Typeclass to handle merging of values.

Methods

merge :: a -> a -> a Source #

Merge two values.

class Required a where Source #

Typeclass to retrieve required WireTags.

Minimal complete definition

reqTags

Methods

reqTags :: a -> Set WireTag Source #

The required WireTags for the data type.

class WireEnum a where Source #

Typeclass to handle encoding en decoding of enums.

Minimal complete definition

intToEnum, enumToInt

Methods

intToEnum :: Int32 -> a Source #

Convert an Int32 to an enum value.

enumToInt :: a -> Int32 Source #

Convert a enum value to an Int32.

class WireMessage a where Source #

Typeclass to handle encoding and decoding of messages.

Minimal complete definition

fieldToValue, messageToFields

Methods

fieldToValue :: WireTag -> a -> Get a Source #

Decode a field and merge it with the existing value in the message.

messageToFields :: a -> Put Source #

Encode all the fields of the message.

data WireTag Source #

Type to represent a wire tag.

fromWireTag :: WireTag -> Word32 Source #

Convert a WireTag into a Word32.

toWireTag :: Word32 -> Either String WireTag Source #

Convert a Word32 into a WireTag or an error.

data WireType Source #

Type to represent the Protocol Buffers wire type.

Constructors

VarInt

The varint type: int32, int64, uint32, sint32, sint64, bool enum

Bit64

The 64-bit type: fixed64, sfixed64, double

LenDelim

The length-delimited: string, bytes, embedded messages, packed repeated fields

Bit32

The 32-bit type: fixed32, sfixed32, float

fromWireType :: WireType -> Word32 Source #

Convert a WireType into a Word32.

toWireType :: Word32 -> Either String WireType Source #

Convert a Word32 into a WireType or an error.

decode :: (Default a, Required a, WireMessage a) => ByteString -> Either String a Source #

Decode a ByteString into either the data-type or an error message.

Decode CustomType:

decCustomType :: ByteString -> Either String CustomType
decCustomType = decode

encode :: WireMessage a => a -> ByteString Source #

Encode a data-type into a ByteString.

Encode CustomType:

encCustomType :: CustomType -> ByteString
encCustomType = encode

getBool :: Get Bool Source #

Decode a required bool field.

getBoolOpt :: Get (Maybe Bool) Source #

Decode an optional bool field.

getBoolPacked :: Get (Seq Bool) Source #

Decode a packed repeated bool field.

getBytes :: Get ByteString Source #

Decode a required bytes field.

getBytesOpt :: Get (Maybe ByteString) Source #

Decode an optional bytes field.

getDouble :: Get Double Source #

Decode a required double field.

getDoubleOpt :: Get (Maybe Double) Source #

Decode an optional double field.

getDoublePacked :: Get (Seq Double) Source #

Decode a packed repeated double field.

getEnum :: WireEnum a => Get a Source #

Decode a required enum field.

getEnumOpt :: WireEnum a => Get (Maybe a) Source #

Decode an optional enum field.

getEnumPacked :: WireEnum a => Get (Seq a) Source #

Decode a packed repeated enum field.

getFixed32 :: Get Word32 Source #

Decode a required fixed32 field.

getFixed32Opt :: Get (Maybe Word32) Source #

Decode an optional fixed32 field.

getFixed32Packed :: Get (Seq Word32) Source #

Decode a packed repeated fixed32 field.

getFixed64 :: Get Word64 Source #

Decode a required fixed64 field.

getFixed64Opt :: Get (Maybe Word64) Source #

Decode an optional fixed64 field.

getFixed64Packed :: Get (Seq Word64) Source #

Decode a packed repeated fixed64 field.

getFloat :: Get Float Source #

Decode a required float field.

getFloatOpt :: Get (Maybe Float) Source #

Decode an optional float field.

getFloatPacked :: Get (Seq Float) Source #

Decode a packed repeated float field.

getGroup :: (Default a, Required a, WireMessage a) => Get a Source #

Decode a required group field.

getGroupOpt :: (Default a, Required a, WireMessage a) => Get (Maybe a) Source #

Decode an optional group field.

getInt32 :: Get Int32 Source #

Decode a required int32 field.

getInt32Opt :: Get (Maybe Int32) Source #

Decode an optional int32 field.

getInt32Packed :: Get (Seq Int32) Source #

Decode a packed repeated int32 field.

getInt64 :: Get Int64 Source #

Decode a required int64 field.

getInt64Opt :: Get (Maybe Int64) Source #

Decode an optional int64 field.

getInt64Packed :: Get (Seq Int64) Source #

Decode a packed repeated int64 field.

getMessage :: (Default a, Required a, WireMessage a) => Get a Source #

Decode a required message field.

getMessageOpt :: (Default a, Required a, WireMessage a) => Get (Maybe a) Source #

Decode an optional message field.

getSFixed32 :: Get Int32 Source #

Decode a required sfixed32 field.

getSFixed32Opt :: Get (Maybe Int32) Source #

Decode an optional sfixed32 field.

getSFixed32Packed :: Get (Seq Int32) Source #

Decode a packed repeated sfixed32 field.

getSFixed64 :: Get Int64 Source #

Decode a required sfixed64 field.

getSFixed64Opt :: Get (Maybe Int64) Source #

Decode an optional sfixed64 field.

getSFixed64Packed :: Get (Seq Int64) Source #

Decode a packed repeated sfixed64 field.

getSInt32 :: Get Int32 Source #

Decode a required sint32 field.

getSInt32Opt :: Get (Maybe Int32) Source #

Decode an optional sint32 field.

getSInt32Packed :: Get (Seq Int32) Source #

Decode a packed repeated sint32 field.

getSInt64 :: Get Int64 Source #

Decode a required sint64 field.

getSInt64Opt :: Get (Maybe Int64) Source #

Decode an optional sint64 field.

getSInt64Packed :: Get (Seq Int64) Source #

Decode a packed repeated sint64 field.

getString :: Get Text Source #

Decode a required string.

getStringOpt :: Get (Maybe Text) Source #

Decode an optional string.

getUInt32 :: Get Word32 Source #

Decode a required uint32 field.

getUInt32Opt :: Get (Maybe Word32) Source #

Decode an optional uint32 field.

getUInt32Packed :: Get (Seq Word32) Source #

Decode a packed repeated uint32 field.

getUInt64 :: Get Word64 Source #

Decode a required uint64 field.

getUInt64Opt :: Get (Maybe Word64) Source #

Decode an optional uint64 field.

getUInt64Packed :: Get (Seq Word64) Source #

Decode a packed repeated uint64 field.

getUnknown :: WireTag -> a -> Get a Source #

Skip an unknown field.

getWireTag :: Get WireTag Source #

Decode a wire tag.

putBool :: WireTag -> Bool -> Put Source #

Encode a required bool field.

putBoolList :: WireTag -> Seq Bool -> Put Source #

Encode a repeated bool field.

putBoolOpt :: WireTag -> Maybe Bool -> Put Source #

Encode an optional bool field.

putBoolPacked :: WireTag -> Seq Bool -> Put Source #

Encode a packed repeated bool field.

putBytes :: WireTag -> ByteString -> Put Source #

Encode a required bytes field.

putBytesList :: WireTag -> Seq ByteString -> Put Source #

Encode a repeated bytes field.

putBytesOpt :: WireTag -> Maybe ByteString -> Put Source #

Encode an optional bytes field.

putDouble :: WireTag -> Double -> Put Source #

Encode a required double field.

putDoubleList :: WireTag -> Seq Double -> Put Source #

Encode a repeated double field.

putDoubleOpt :: WireTag -> Maybe Double -> Put Source #

Encode an optional double field.

putDoublePacked :: WireTag -> Seq Double -> Put Source #

Encode a packed repeated double field.

putEnum :: WireEnum a => WireTag -> a -> Put Source #

Encode a required enum field.

putEnumList :: WireEnum a => WireTag -> Seq a -> Put Source #

Encode a repeated enum field.

putEnumOpt :: WireEnum a => WireTag -> Maybe a -> Put Source #

Encode an optional enum field.

putEnumPacked :: WireEnum a => WireTag -> Seq a -> Put Source #

Encode a packed repeated enum field.

putFixed32 :: WireTag -> Word32 -> Put Source #

Encode a required fixed32 field.

putFixed32List :: WireTag -> Seq Word32 -> Put Source #

Encode a repeated fixed32 field.

putFixed32Opt :: WireTag -> Maybe Word32 -> Put Source #

Encode an optional fixed32 field.

putFixed32Packed :: WireTag -> Seq Word32 -> Put Source #

Encode a packed repeated fixed32 field.

putFixed64 :: WireTag -> Word64 -> Put Source #

Encode a required fixed64 field.

putFixed64List :: WireTag -> Seq Word64 -> Put Source #

Encode a repeated fixed64 field.

putFixed64Opt :: WireTag -> Maybe Word64 -> Put Source #

Encode an optional fixed64 field.

putFixed64Packed :: WireTag -> Seq Word64 -> Put Source #

Encode a packed repeated fixed64 field.

putFloat :: WireTag -> Float -> Put Source #

Encode a required float field.

putFloatList :: WireTag -> Seq Float -> Put Source #

Encode a repeated float field.

putFloatOpt :: WireTag -> Maybe Float -> Put Source #

Encode an optional float field.

putFloatPacked :: WireTag -> Seq Float -> Put Source #

Encode a packed repeated float field.

putGroup :: WireMessage a => a -> Put Source #

Encode a required group field.

putGroupOpt :: WireMessage a => Maybe a -> Put Source #

Encode an optional group field.

putInt32 :: WireTag -> Int32 -> Put Source #

Encode a required int32 field.

putInt32List :: WireTag -> Seq Int32 -> Put Source #

Encode a repeated int32 field.

putInt32Opt :: WireTag -> Maybe Int32 -> Put Source #

Encode an optional int32 field.

putInt32Packed :: WireTag -> Seq Int32 -> Put Source #

Encode a packed repeated int32 field.

putInt64 :: WireTag -> Int64 -> Put Source #

Encode a required int64 field.

putInt64List :: WireTag -> Seq Int64 -> Put Source #

Encode a repeated int64 field.

putInt64Opt :: WireTag -> Maybe Int64 -> Put Source #

Encode an optional int64 field.

putInt64Packed :: WireTag -> Seq Int64 -> Put Source #

Encode a packed repeated int64 field.

putSFixed32 :: WireTag -> Int32 -> Put Source #

Encode a required sfixed32 field.

putSFixed32List :: WireTag -> Seq Int32 -> Put Source #

Encode a repeated sfixed32 field.

putSFixed32Opt :: WireTag -> Maybe Int32 -> Put Source #

Encode an optional sfixed32 field.

putSFixed32Packed :: WireTag -> Seq Int32 -> Put Source #

Encode a packed repeated sfixed32 field.

putSFixed64 :: WireTag -> Int64 -> Put Source #

Encode a required sfixed64 field.

putSFixed64List :: WireTag -> Seq Int64 -> Put Source #

Encode a repeated sfixed64 field.

putSFixed64Opt :: WireTag -> Maybe Int64 -> Put Source #

Encode an optional sfixed64 field.

putSFixed64Packed :: WireTag -> Seq Int64 -> Put Source #

Encode a packed repeated sfixed64 field.

putSInt32 :: WireTag -> Int32 -> Put Source #

Encode a required sint32 field.

putSInt32List :: WireTag -> Seq Int32 -> Put Source #

Encode a repeated sint32 field.

putSInt32Opt :: WireTag -> Maybe Int32 -> Put Source #

Encode an optional sint32 field.

putSInt32Packed :: WireTag -> Seq Int32 -> Put Source #

Encode a packed repeated sint32 field.

putSInt64 :: WireTag -> Int64 -> Put Source #

Encode a required sint64 field.

putSInt64List :: WireTag -> Seq Int64 -> Put Source #

Encode a repeated sint64 field.

putSInt64Opt :: WireTag -> Maybe Int64 -> Put Source #

Encode an optional sint64 field.

putSInt64Packed :: WireTag -> Seq Int64 -> Put Source #

Encode a packed repeated sint64 field.

putMessage :: WireMessage a => WireTag -> a -> Put Source #

Encode a required message field.

putMessageList :: WireMessage a => WireTag -> Seq a -> Put Source #

Encode a repeated message field.

putMessageOpt :: WireMessage a => WireTag -> Maybe a -> Put Source #

Encode an optional message field.

putString :: WireTag -> Text -> Put Source #

Encode a required string field.

putStringList :: WireTag -> Seq Text -> Put Source #

Encode a repeated string field.

putStringOpt :: WireTag -> Maybe Text -> Put Source #

Encode an optional string field.

putUInt32 :: WireTag -> Word32 -> Put Source #

Encode a required uint32 field.

putUInt32List :: WireTag -> Seq Word32 -> Put Source #

Encode a repeated uint32 field.

putUInt32Opt :: WireTag -> Maybe Word32 -> Put Source #

Encode an optional uint32 field.

putUInt32Packed :: WireTag -> Seq Word32 -> Put Source #

Encode a packed repeated uint32 field.

putUInt64 :: WireTag -> Word64 -> Put Source #

Encode a required uint64 field.

putUInt64List :: WireTag -> Seq Word64 -> Put Source #

Encode a repeated uint64 field.

putUInt64Opt :: WireTag -> Maybe Word64 -> Put Source #

Encode an optional uint64 field.

putUInt64Packed :: WireTag -> Seq Word64 -> Put Source #

Encode a packed repeated uint64 field.

putWireTag :: WireTag -> Put Source #

Encode a wire tag.

class WireMessage a where Source #

Typeclass to handle encoding and decoding of messages.

Minimal complete definition

fieldToValue, messageToFields

Methods

fieldToValue :: WireTag -> a -> Get a Source #

Decode a field and merge it with the existing value in the message.

messageToFields :: a -> Put Source #

Encode all the fields of the message.

data WireTag Source #

Type to represent a wire tag.

fromWireTag :: WireTag -> Word32 Source #

Convert a WireTag into a Word32.

toWireTag :: Word32 -> Either String WireTag Source #

Convert a Word32 into a WireTag or an error.

data WireType Source #

Type to represent the Protocol Buffers wire type.

Constructors

VarInt

The varint type: int32, int64, uint32, sint32, sint64, bool enum

Bit64

The 64-bit type: fixed64, sfixed64, double

LenDelim

The length-delimited: string, bytes, embedded messages, packed repeated fields

Bit32

The 32-bit type: fixed32, sfixed32, float

fromWireType :: WireType -> Word32 Source #

Convert a WireType into a Word32.

toWireType :: Word32 -> Either String WireType Source #

Convert a Word32 into a WireType or an error.

append :: Seq a -> a -> Seq a Source #

Append a value to a Seq.