-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasks.queueStats.go
236 lines (217 loc) · 7.12 KB
/
tasks.queueStats.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
// 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 tlTasksQueueStats
import (
"github.com/vkcom/tl/internal/tlcodegen/test/gen/schema/internal"
"github.com/vkcom/tl/pkg/basictl"
)
var _ = basictl.NatWrite
var _ = internal.ErrorInvalidEnumTag
type TasksQueueStats struct {
WaitingSize int32 // Conditional: nat_fields_mask.0
ScheduledSize int32 // Conditional: nat_fields_mask.1
InProgressSize int32 // Conditional: nat_fields_mask.2
}
func (TasksQueueStats) TLName() string { return "tasks.queueStats" }
func (TasksQueueStats) TLTag() uint32 { return 0x1d942543 }
func (item *TasksQueueStats) SetWaitingSize(v int32, nat_fields_mask *uint32) {
item.WaitingSize = v
if nat_fields_mask != nil {
*nat_fields_mask |= 1 << 0
}
}
func (item *TasksQueueStats) ClearWaitingSize(nat_fields_mask *uint32) {
item.WaitingSize = 0
if nat_fields_mask != nil {
*nat_fields_mask &^= 1 << 0
}
}
func (item TasksQueueStats) IsSetWaitingSize(nat_fields_mask uint32) bool {
return nat_fields_mask&(1<<0) != 0
}
func (item *TasksQueueStats) SetScheduledSize(v int32, nat_fields_mask *uint32) {
item.ScheduledSize = v
if nat_fields_mask != nil {
*nat_fields_mask |= 1 << 1
}
}
func (item *TasksQueueStats) ClearScheduledSize(nat_fields_mask *uint32) {
item.ScheduledSize = 0
if nat_fields_mask != nil {
*nat_fields_mask &^= 1 << 1
}
}
func (item TasksQueueStats) IsSetScheduledSize(nat_fields_mask uint32) bool {
return nat_fields_mask&(1<<1) != 0
}
func (item *TasksQueueStats) SetInProgressSize(v int32, nat_fields_mask *uint32) {
item.InProgressSize = v
if nat_fields_mask != nil {
*nat_fields_mask |= 1 << 2
}
}
func (item *TasksQueueStats) ClearInProgressSize(nat_fields_mask *uint32) {
item.InProgressSize = 0
if nat_fields_mask != nil {
*nat_fields_mask &^= 1 << 2
}
}
func (item TasksQueueStats) IsSetInProgressSize(nat_fields_mask uint32) bool {
return nat_fields_mask&(1<<2) != 0
}
func (item *TasksQueueStats) Reset() {
item.WaitingSize = 0
item.ScheduledSize = 0
item.InProgressSize = 0
}
func (item *TasksQueueStats) Read(w []byte, nat_fields_mask uint32) (_ []byte, err error) {
if nat_fields_mask&(1<<0) != 0 {
if w, err = basictl.IntRead(w, &item.WaitingSize); err != nil {
return w, err
}
} else {
item.WaitingSize = 0
}
if nat_fields_mask&(1<<1) != 0 {
if w, err = basictl.IntRead(w, &item.ScheduledSize); err != nil {
return w, err
}
} else {
item.ScheduledSize = 0
}
if nat_fields_mask&(1<<2) != 0 {
if w, err = basictl.IntRead(w, &item.InProgressSize); err != nil {
return w, err
}
} else {
item.InProgressSize = 0
}
return w, nil
}
// This method is general version of Write, use it instead!
func (item *TasksQueueStats) WriteGeneral(w []byte, nat_fields_mask uint32) (_ []byte, err error) {
return item.Write(w, nat_fields_mask), nil
}
func (item *TasksQueueStats) Write(w []byte, nat_fields_mask uint32) []byte {
if nat_fields_mask&(1<<0) != 0 {
w = basictl.IntWrite(w, item.WaitingSize)
}
if nat_fields_mask&(1<<1) != 0 {
w = basictl.IntWrite(w, item.ScheduledSize)
}
if nat_fields_mask&(1<<2) != 0 {
w = basictl.IntWrite(w, item.InProgressSize)
}
return w
}
func (item *TasksQueueStats) ReadBoxed(w []byte, nat_fields_mask uint32) (_ []byte, err error) {
if w, err = basictl.NatReadExactTag(w, 0x1d942543); err != nil {
return w, err
}
return item.Read(w, nat_fields_mask)
}
// This method is general version of WriteBoxed, use it instead!
func (item *TasksQueueStats) WriteBoxedGeneral(w []byte, nat_fields_mask uint32) (_ []byte, err error) {
return item.WriteBoxed(w, nat_fields_mask), nil
}
func (item *TasksQueueStats) WriteBoxed(w []byte, nat_fields_mask uint32) []byte {
w = basictl.NatWrite(w, 0x1d942543)
return item.Write(w, nat_fields_mask)
}
func (item *TasksQueueStats) ReadJSON(legacyTypeNames bool, in *basictl.JsonLexer, nat_fields_mask uint32) error {
var propWaitingSizePresented bool
var propScheduledSizePresented bool
var propInProgressSizePresented bool
if in != nil {
in.Delim('{')
if !in.Ok() {
return in.Error()
}
for !in.IsDelim('}') {
key := in.UnsafeFieldName(true)
in.WantColon()
switch key {
case "waiting_size":
if propWaitingSizePresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("tasks.queueStats", "waiting_size")
}
if nat_fields_mask&(1<<0) == 0 {
return internal.ErrorInvalidJSON("tasks.queueStats", "field 'waiting_size' is defined, while corresponding implicit fieldmask bit is 0")
}
if err := internal.Json2ReadInt32(in, &item.WaitingSize); err != nil {
return err
}
propWaitingSizePresented = true
case "scheduled_size":
if propScheduledSizePresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("tasks.queueStats", "scheduled_size")
}
if nat_fields_mask&(1<<1) == 0 {
return internal.ErrorInvalidJSON("tasks.queueStats", "field 'scheduled_size' is defined, while corresponding implicit fieldmask bit is 0")
}
if err := internal.Json2ReadInt32(in, &item.ScheduledSize); err != nil {
return err
}
propScheduledSizePresented = true
case "in_progress_size":
if propInProgressSizePresented {
return internal.ErrorInvalidJSONWithDuplicatingKeys("tasks.queueStats", "in_progress_size")
}
if nat_fields_mask&(1<<2) == 0 {
return internal.ErrorInvalidJSON("tasks.queueStats", "field 'in_progress_size' is defined, while corresponding implicit fieldmask bit is 0")
}
if err := internal.Json2ReadInt32(in, &item.InProgressSize); err != nil {
return err
}
propInProgressSizePresented = true
default:
return internal.ErrorInvalidJSONExcessElement("tasks.queueStats", key)
}
in.WantComma()
}
in.Delim('}')
if !in.Ok() {
return in.Error()
}
}
if !propWaitingSizePresented {
item.WaitingSize = 0
}
if !propScheduledSizePresented {
item.ScheduledSize = 0
}
if !propInProgressSizePresented {
item.InProgressSize = 0
}
return nil
}
// This method is general version of WriteJSON, use it instead!
func (item *TasksQueueStats) WriteJSONGeneral(w []byte, nat_fields_mask uint32) (_ []byte, err error) {
return item.WriteJSONOpt(true, false, w, nat_fields_mask), nil
}
func (item *TasksQueueStats) WriteJSON(w []byte, nat_fields_mask uint32) []byte {
return item.WriteJSONOpt(true, false, w, nat_fields_mask)
}
func (item *TasksQueueStats) WriteJSONOpt(newTypeNames bool, short bool, w []byte, nat_fields_mask uint32) []byte {
w = append(w, '{')
if nat_fields_mask&(1<<0) != 0 {
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"waiting_size":`...)
w = basictl.JSONWriteInt32(w, item.WaitingSize)
}
if nat_fields_mask&(1<<1) != 0 {
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"scheduled_size":`...)
w = basictl.JSONWriteInt32(w, item.ScheduledSize)
}
if nat_fields_mask&(1<<2) != 0 {
w = basictl.JSONAddCommaIfNeeded(w)
w = append(w, `"in_progress_size":`...)
w = basictl.JSONWriteInt32(w, item.InProgressSize)
}
return append(w, '}')
}