-
Notifications
You must be signed in to change notification settings - Fork 2
/
cases.testTuple.go
130 lines (110 loc) · 3.62 KB
/
cases.testTuple.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
// Copyright 2022 V Kontakte LLC
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Code generated by vktl/cmd/tlgen2; DO NOT EDIT.
package tlCasesTestTuple
import (
"github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal"
"github.com/vkcom/tl/internal/tlcodegen/test/gen/cases/internal/tl/tlBuiltinTuple4Int"
"github.com/vkcom/tl/pkg/basictl"
)
var _ = basictl.NatWrite
var _ = internal.ErrorInvalidEnumTag
type CasesTestTuple struct {
Tpl [4]int32
}
func (CasesTestTuple) TLName() string { return "cases.testTuple" }
func (CasesTestTuple) TLTag() uint32 { return 0x4b9caf8f }
func (item *CasesTestTuple) Reset() {
tlBuiltinTuple4Int.BuiltinTuple4IntReset(&item.Tpl)
}
func (item *CasesTestTuple) FillRandom(rg *basictl.RandGenerator) {
tlBuiltinTuple4Int.BuiltinTuple4IntFillRandom(rg, &item.Tpl)
}
func (item *CasesTestTuple) Read(w []byte) (_ []byte, err error) {
return tlBuiltinTuple4Int.BuiltinTuple4IntRead(w, &item.Tpl)
}
// This method is general version of Write, use it instead!
func (item *CasesTestTuple) WriteGeneral(w []byte) (_ []byte, err error) {
return item.Write(w), nil
}
func (item *CasesTestTuple) Write(w []byte) []byte {
w = tlBuiltinTuple4Int.BuiltinTuple4IntWrite(w, &item.Tpl)
return w
}
func (item *CasesTestTuple) ReadBoxed(w []byte) (_ []byte, err error) {
if w, err = basictl.NatReadExactTag(w, 0x4b9caf8f); err != nil {
return w, err
}
return item.Read(w)
}
// This method is general version of WriteBoxed, use it instead!
func (item *CasesTestTuple) WriteBoxedGeneral(w []byte) (_ []byte, err error) {
return item.WriteBoxed(w), nil
}
func (item *CasesTestTuple) WriteBoxed(w []byte) []byte {
w = basictl.NatWrite(w, 0x4b9caf8f)
return item.Write(w)
}
func (item CasesTestTuple) String() string {
return string(item.WriteJSON(nil))
}
func (item *CasesTestTuple) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer) error {
var propTplPresented bool
if in != nil {
in.Delim('{')
if !in.Ok() {
return in.Error()
}
for !in.IsDelim('}') {
key := in.UnsafeFieldName(true)
in.WantColon()
switch key {
case "tpl":
if propTplPresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("cases.testTuple", "tpl")
}
if err := tlBuiltinTuple4Int.BuiltinTuple4IntReadJSON(legacyTypeNames, in, &item.Tpl); err != nil {
return err
}
propTplPresented = true
default:
return internal.ErrorInvalidJSONExcessElement("cases.testTuple", key)
}
in.WantComma()
}
in.Delim('}')
if !in.Ok() {
return in.Error()
}
}
if !propTplPresented {
tlBuiltinTuple4Int.BuiltinTuple4IntReset(&item.Tpl)
}
return nil
}
// This method is general version of WriteJSON, use it instead!
func (item *CasesTestTuple) WriteJSONGeneral(w []byte) (_ []byte, err error) {
return item.WriteJSONOpt(true, false, w), nil
}
func (item *CasesTestTuple) WriteJSON(w []byte) []byte {
return item.WriteJSONOpt(true, false, w)
}
func (item *CasesTestTuple) WriteJSONOpt(newTypeNames bool, short bool, w []byte) []byte {
w = append(w, '{')
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"tpl":`...)
w = tlBuiltinTuple4Int.BuiltinTuple4IntWriteJSONOpt(newTypeNames, short, w, &item.Tpl)
return append(w, '}')
}
func (item *CasesTestTuple) MarshalJSON() ([]byte, error) {
return item.WriteJSON(nil), nil
}
func (item *CasesTestTuple) UnmarshalJSON(b []byte) error {
if err := item.ReadJSON(true, &basictl.JsonLexer{Data: b}); err != nil {
return internal.ErrorInvalidJSON("cases.testTuple", err.Error())
}
return nil
}