-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple_struct.ex
36 lines (29 loc) · 897 Bytes
/
simple_struct.ex
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
defmodule TacoType do
use Thrash.Enumerated
end
defmodule ProperNamesForColdFizzyDrinks do
use Thrash.Enumerated
end
defmodule TacoFlavor do
use Thrash.Enumerated, source: TacoType
end
defmodule SubStruct do
use Thrash.Protocol.Binary
end
defmodule Constants do
use Thrash.Constants
end
defmodule SimpleStruct do
use Thrash.Protocol.Binary, defaults: [taco_pref: :chicken],
types: [taco_pref: {:enum, TacoType}]
end
defmodule InnerStruct do
use Thrash.Protocol.Binary, source: SubStruct
end
defmodule OuterStruct do
use Thrash.Protocol.Binary, source: SimpleStruct,
defaults: [taco_pref: :chicken,
sub_struct: %InnerStruct{}],
types: [taco_pref: {:enum, TacoType},
sub_struct: {:struct, InnerStruct}]
end