-
Notifications
You must be signed in to change notification settings - Fork 179
/
option_bytes.go
429 lines (347 loc) · 11.6 KB
/
option_bytes.go
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
// Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls
//
// Copyright 2019 Centrifuge GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package types
import "github.com/centrifuge/go-substrate-rpc-client/v4/scale"
// OptionBytes is a structure that can store a Bytes or a missing value
type OptionBytes struct {
option
value Bytes
}
// NewOptionBytes creates an OptionBytes with a value
func NewOptionBytes(value Bytes) OptionBytes {
return OptionBytes{option{true}, value}
}
// NewOptionBytesEmpty creates an OptionBytes without a value
func NewOptionBytesEmpty() OptionBytes {
return OptionBytes{option: option{false}}
}
func (o OptionBytes) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes) SetSome(value Bytes) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes) SetNone() {
o.hasValue = false
o.value = Bytes{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes) Unwrap() (ok bool, value Bytes) {
return o.hasValue, o.value
}
// OptionBytes8 is a structure that can store a Bytes8 or a missing value
type OptionBytes8 struct {
option
value Bytes8
}
// NewOptionBytes8 creates an OptionBytes8 with a value
func NewOptionBytes8(value Bytes8) OptionBytes8 {
return OptionBytes8{option{true}, value}
}
// NewOptionBytes8Empty creates an OptionBytes8 without a value
func NewOptionBytes8Empty() OptionBytes8 {
return OptionBytes8{option: option{false}}
}
func (o OptionBytes8) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes8) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes8) SetSome(value Bytes8) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes8) SetNone() {
o.hasValue = false
o.value = Bytes8{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes8) Unwrap() (ok bool, value Bytes8) {
return o.hasValue, o.value
}
// OptionBytes16 is a structure that can store a Bytes16 or a missing value
type OptionBytes16 struct {
option
value Bytes16
}
// NewOptionBytes16 creates an OptionBytes16 with a value
func NewOptionBytes16(value Bytes16) OptionBytes16 {
return OptionBytes16{option{true}, value}
}
// NewOptionBytes16Empty creates an OptionBytes16 without a value
func NewOptionBytes16Empty() OptionBytes16 {
return OptionBytes16{option: option{false}}
}
func (o OptionBytes16) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes16) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes16) SetSome(value Bytes16) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes16) SetNone() {
o.hasValue = false
o.value = Bytes16{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes16) Unwrap() (ok bool, value Bytes16) {
return o.hasValue, o.value
}
// OptionBytes32 is a structure that can store a Bytes32 or a missing value
type OptionBytes32 struct {
option
value Bytes32
}
// NewOptionBytes32 creates an OptionBytes32 with a value
func NewOptionBytes32(value Bytes32) OptionBytes32 {
return OptionBytes32{option{true}, value}
}
// NewOptionBytes32Empty creates an OptionBytes32 without a value
func NewOptionBytes32Empty() OptionBytes32 {
return OptionBytes32{option: option{false}}
}
func (o OptionBytes32) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes32) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes32) SetSome(value Bytes32) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes32) SetNone() {
o.hasValue = false
o.value = Bytes32{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes32) Unwrap() (ok bool, value Bytes32) {
return o.hasValue, o.value
}
// OptionBytes64 is a structure that can store a Bytes64 or a missing value
type OptionBytes64 struct {
option
value Bytes64
}
// NewOptionBytes64 creates an OptionBytes64 with a value
func NewOptionBytes64(value Bytes64) OptionBytes64 {
return OptionBytes64{option{true}, value}
}
// NewOptionBytes64Empty creates an OptionBytes64 without a value
func NewOptionBytes64Empty() OptionBytes64 {
return OptionBytes64{option: option{false}}
}
func (o OptionBytes64) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes64) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes64) SetSome(value Bytes64) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes64) SetNone() {
o.hasValue = false
o.value = Bytes64{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes64) Unwrap() (ok bool, value Bytes64) {
return o.hasValue, o.value
}
// OptionBytes128 is a structure that can store a Bytes128 or a missing value
type OptionBytes128 struct {
option
value Bytes128
}
// NewOptionBytes128 creates an OptionBytes128 with a value
func NewOptionBytes128(value Bytes128) OptionBytes128 {
return OptionBytes128{option{true}, value}
}
// NewOptionBytes128Empty creates an OptionBytes128 without a value
func NewOptionBytes128Empty() OptionBytes128 {
return OptionBytes128{option: option{false}}
}
func (o OptionBytes128) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes128) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes128) SetSome(value Bytes128) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes128) SetNone() {
o.hasValue = false
o.value = Bytes128{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes128) Unwrap() (ok bool, value Bytes128) {
return o.hasValue, o.value
}
// OptionBytes256 is a structure that can store a Bytes256 or a missing value
type OptionBytes256 struct {
option
value Bytes256
}
// NewOptionBytes256 creates an OptionBytes256 with a value
func NewOptionBytes256(value Bytes256) OptionBytes256 {
return OptionBytes256{option{true}, value}
}
// NewOptionBytes256Empty creates an OptionBytes256 without a value
func NewOptionBytes256Empty() OptionBytes256 {
return OptionBytes256{option: option{false}}
}
func (o OptionBytes256) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes256) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes256) SetSome(value Bytes256) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes256) SetNone() {
o.hasValue = false
o.value = Bytes256{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes256) Unwrap() (ok bool, value Bytes256) {
return o.hasValue, o.value
}
// OptionBytes512 is a structure that can store a Bytes512 or a missing value
type OptionBytes512 struct {
option
value Bytes512
}
// NewOptionBytes512 creates an OptionBytes512 with a value
func NewOptionBytes512(value Bytes512) OptionBytes512 {
return OptionBytes512{option{true}, value}
}
// NewOptionBytes512Empty creates an OptionBytes512 without a value
func NewOptionBytes512Empty() OptionBytes512 {
return OptionBytes512{option: option{false}}
}
func (o OptionBytes512) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes512) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes512) SetSome(value Bytes512) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes512) SetNone() {
o.hasValue = false
o.value = Bytes512{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes512) Unwrap() (ok bool, value Bytes512) {
return o.hasValue, o.value
}
// OptionBytes1024 is a structure that can store a Bytes1024 or a missing value
type OptionBytes1024 struct {
option
value Bytes1024
}
// NewOptionBytes1024 creates an OptionBytes1024 with a value
func NewOptionBytes1024(value Bytes1024) OptionBytes1024 {
return OptionBytes1024{option{true}, value}
}
// NewOptionBytes1024Empty creates an OptionBytes1024 without a value
func NewOptionBytes1024Empty() OptionBytes1024 {
return OptionBytes1024{option: option{false}}
}
func (o OptionBytes1024) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes1024) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes1024) SetSome(value Bytes1024) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes1024) SetNone() {
o.hasValue = false
o.value = Bytes1024{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes1024) Unwrap() (ok bool, value Bytes1024) {
return o.hasValue, o.value
}
// OptionBytes2048 is a structure that can store a Bytes2048 or a missing value
type OptionBytes2048 struct {
option
value Bytes2048
}
// NewOptionBytes2048 creates an OptionBytes2048 with a value
func NewOptionBytes2048(value Bytes2048) OptionBytes2048 {
return OptionBytes2048{option{true}, value}
}
// NewOptionBytes2048Empty creates an OptionBytes2048 without a value
func NewOptionBytes2048Empty() OptionBytes2048 {
return OptionBytes2048{option: option{false}}
}
func (o OptionBytes2048) Encode(encoder scale.Encoder) error {
return encoder.EncodeOption(o.hasValue, o.value)
}
func (o *OptionBytes2048) Decode(decoder scale.Decoder) error {
return decoder.DecodeOption(&o.hasValue, &o.value)
}
// SetSome sets a value
func (o *OptionBytes2048) SetSome(value Bytes2048) {
o.hasValue = true
o.value = value
}
// SetNone removes a value and marks it as missing
func (o *OptionBytes2048) SetNone() {
o.hasValue = false
o.value = Bytes2048{}
}
// Unwrap returns a flag that indicates whether a value is present and the stored value
func (o OptionBytes2048) Unwrap() (ok bool, value Bytes2048) {
return o.hasValue, o.value
}