forked from feral-dot-io/protoc-gen-elmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ex01Records.elm
72 lines (43 loc) · 2.08 KB
/
Ex01Records.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Ex01Records exposing (..)
{-| Protobuf library for decoding and encoding structures found in 01-records.proto along with helpers. This file was generated automatically by `protoc-gen-elmer`. Do not edit.
Records:
- MyFirstMessage
Unions: (none)
Each type defined has a: decoder, encoder and an empty (zero value) function. In addition to this enums have valuesOf, to and from (string) functions. All functions take the form `decodeDerivedIdent` where `decode` is the purpose and `DerivedIdent` comes from the Protobuf ident.
Elm identifiers are derived directly from the Protobuf ID (a full ident). The package maps to a module and the rest of the ID is the type. Since Protobuf names are hierachical (separated by a dot `.`), each namespace is mapped to an underscore `_` in an Elm ID. A Protobuf namespaced ident (parts between a dot `.`) are then cased to follow Elm naming conventions and do not include any undescores `_`. For example the enum `my.pkg.MyMessage.URLOptions` maps to the Elm module `My.Pkg` with ID `MyMessage_UrlOptions`.
# Types
@docs MyFirstMessage
# Empty (zero values)
@docs emptyMyFirstMessage
# Decoders
@docs decodeMyFirstMessage
# Encoders
@docs encodeMyFirstMessage
-}
-- // Code generated protoc-gen-elmer DO NOT EDIT \\
import Protobuf.Decode as PD
import Protobuf.Encode as PE
{-| Our very first Protobuf!
-}
type alias MyFirstMessage =
{ myFirstFloat : Float
, myFavouriteNumber : Int
, onOrOff : Bool
}
emptyMyFirstMessage : MyFirstMessage
emptyMyFirstMessage =
MyFirstMessage 0 0 False
decodeMyFirstMessage : PD.Decoder MyFirstMessage
decodeMyFirstMessage =
PD.message emptyMyFirstMessage
[ PD.optional 2 PD.double (\v m -> { m | myFirstFloat = v })
, PD.optional 1 PD.int32 (\v m -> { m | myFavouriteNumber = v })
, PD.optional 3 PD.bool (\v m -> { m | onOrOff = v })
]
encodeMyFirstMessage : MyFirstMessage -> PE.Encoder
encodeMyFirstMessage v =
PE.message <|
[ ( 2, PE.double v.myFirstFloat )
, ( 1, PE.int32 v.myFavouriteNumber )
, ( 3, PE.bool v.onOrOff )
]