-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
config_setting_entry.ex
103 lines (87 loc) · 3.2 KB
/
config_setting_entry.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
defmodule StellarBase.XDR.ConfigSettingEntry do
@moduledoc """
Automatically generated by xdrgen
DO NOT EDIT or your changes may be overwritten
Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr
Representation of Stellar `ConfigSettingEntry` type.
"""
@behaviour XDR.Declaration
alias StellarBase.XDR.{
ConfigSettingID,
UInt32,
ConfigSettingContractComputeV0,
ConfigSettingContractLedgerCostV0,
ConfigSettingContractHistoricalDataV0,
ConfigSettingContractEventsV0,
ConfigSettingContractBandwidthV0,
ContractCostParams,
StateArchivalSettings,
ConfigSettingContractExecutionLanesV0,
UInt64List,
EvictionIterator
}
@arms [
CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES: UInt32,
CONFIG_SETTING_CONTRACT_COMPUTE_V0: ConfigSettingContractComputeV0,
CONFIG_SETTING_CONTRACT_LEDGER_COST_V0: ConfigSettingContractLedgerCostV0,
CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0: ConfigSettingContractHistoricalDataV0,
CONFIG_SETTING_CONTRACT_EVENTS_V0: ConfigSettingContractEventsV0,
CONFIG_SETTING_CONTRACT_BANDWIDTH_V0: ConfigSettingContractBandwidthV0,
CONFIG_SETTING_CONTRACT_COST_PARAMS_CPU_INSTRUCTIONS: ContractCostParams,
CONFIG_SETTING_CONTRACT_COST_PARAMS_MEMORY_BYTES: ContractCostParams,
CONFIG_SETTING_CONTRACT_DATA_KEY_SIZE_BYTES: UInt32,
CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: UInt32,
CONFIG_SETTING_STATE_ARCHIVAL: StateArchivalSettings,
CONFIG_SETTING_CONTRACT_EXECUTION_LANES: ConfigSettingContractExecutionLanesV0,
CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW: UInt64List,
CONFIG_SETTING_EVICTION_ITERATOR: EvictionIterator
]
@type value ::
UInt32.t()
| ConfigSettingContractComputeV0.t()
| ConfigSettingContractLedgerCostV0.t()
| ConfigSettingContractHistoricalDataV0.t()
| ConfigSettingContractEventsV0.t()
| ConfigSettingContractBandwidthV0.t()
| ContractCostParams.t()
| StateArchivalSettings.t()
| ConfigSettingContractExecutionLanesV0.t()
| UInt64List.t()
| EvictionIterator.t()
@type t :: %__MODULE__{value: value(), type: ConfigSettingID.t()}
defstruct [:value, :type]
@spec new(value :: value(), type :: ConfigSettingID.t()) :: t()
def new(value, %ConfigSettingID{} = type), do: %__MODULE__{value: value, type: type}
@impl true
def encode_xdr(%__MODULE__{value: value, type: type}) do
type
|> XDR.Union.new(@arms, value)
|> XDR.Union.encode_xdr()
end
@impl true
def encode_xdr!(%__MODULE__{value: value, type: type}) do
type
|> XDR.Union.new(@arms, value)
|> XDR.Union.encode_xdr!()
end
@impl true
def decode_xdr(bytes, spec \\ union_spec())
def decode_xdr(bytes, spec) do
case XDR.Union.decode_xdr(bytes, spec) do
{:ok, {{type, value}, rest}} -> {:ok, {new(value, type), rest}}
error -> error
end
end
@impl true
def decode_xdr!(bytes, spec \\ union_spec())
def decode_xdr!(bytes, spec) do
{{type, value}, rest} = XDR.Union.decode_xdr!(bytes, spec)
{new(value, type), rest}
end
@spec union_spec() :: XDR.Union.t()
defp union_spec do
nil
|> ConfigSettingID.new()
|> XDR.Union.new(@arms)
end
end