generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 8
/
fastpb.go
376 lines (313 loc) · 11.2 KB
/
fastpb.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
/*
* Copyright 2022 CloudWeGo Authors
*
* 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 fastpb
// Reader is designed for generating code.
type Reader interface {
FastRead(buf []byte, _type int8, number int32) (n int, err error)
}
// Writer is designed for generating code.
type Writer interface {
Sizer
FastWrite(buf []byte) (n int)
}
// Sizer is designed for generating code.
type Sizer interface {
Size() (n int)
}
// Protocol .
type Protocol interface {
WriteMessage(buf []byte, number int32, writer Writer) (n int)
WriteListPacked(buf []byte, number int32, length int, single Marshal) (n int)
WriteMapEntry(buf []byte, number int32, entry Marshal) (n int)
WriteBool(buf []byte, number int32, value bool) (n int)
WriteInt32(buf []byte, number, value int32) (n int)
WriteInt64(buf []byte, number int32, value int64) (n int)
WriteUint32(buf []byte, number int32, value uint32) (n int)
WriteUint64(buf []byte, number int32, value uint64) (n int)
WriteSint32(buf []byte, number, value int32) (n int)
WriteSint64(buf []byte, number int32, value int64) (n int)
WriteFloat(buf []byte, number int32, value float32) (n int)
WriteDouble(buf []byte, number int32, value float64) (n int)
WriteFixed32(buf []byte, number int32, value uint32) (n int)
WriteFixed64(buf []byte, number int32, value uint64) (n int)
WriteSfixed32(buf []byte, number, value int32) (n int)
WriteSfixed64(buf []byte, number int32, value int64) (n int)
WriteString(buf []byte, number int32, value string) (n int)
WriteBytes(buf []byte, number int32, value []byte) (n int)
ReadMessage(buf []byte, _type int8, reader Reader) (offset int, err error)
ReadList(buf []byte, _type int8, single Unmarshal) (n int, err error)
ReadMapEntry(buf []byte, _type int8, umk, umv Unmarshal) (int, error)
ReadBool(buf []byte, _type int8) (value bool, n int, err error)
ReadInt32(buf []byte, _type int8) (value int32, n int, err error)
ReadInt64(buf []byte, _type int8) (value int64, n int, err error)
ReadUint32(buf []byte, _type int8) (value uint32, n int, err error)
ReadUint64(buf []byte, _type int8) (value uint64, n int, err error)
ReadSint32(buf []byte, _type int8) (value int32, n int, err error)
ReadSint64(buf []byte, _type int8) (value int64, n int, err error)
ReadFloat(buf []byte, _type int8) (value float32, n int, err error)
ReadDouble(buf []byte, _type int8) (value float64, n int, err error)
ReadFixed32(buf []byte, _type int8) (value uint32, n int, err error)
ReadFixed64(buf []byte, _type int8) (value uint64, n int, err error)
ReadSfixed32(buf []byte, _type int8) (value int32, n int, err error)
ReadSfixed64(buf []byte, _type int8) (value int64, n int, err error)
ReadString(buf []byte, _type int8) (value string, n int, err error)
ReadBytes(buf []byte, _type int8) (value []byte, n int, err error)
SizeBool(number int32, value bool) (n int)
SizeInt32(number, value int32) (n int)
SizeInt64(number int32, value int64) (n int)
SizeUint32(number int32, value uint32) (n int)
SizeUint64(number int32, value uint64) (n int)
SizeSint32(number, value int32) (n int)
SizeSint64(number int32, value int64) (n int)
SizeFloat(number int32, value float32) (n int)
SizeDouble(number int32, value float64) (n int)
SizeFixed32(number int32, value uint32) (n int)
SizeFixed64(number int32, value uint64) (n int)
SizeSfixed32(number, value int32) (n int)
SizeSfixed64(number int32, value int64) (n int)
SizeString(number int32, value string) (n int)
SizeBytes(number int32, value []byte) (n int)
SizeMessage(number int32, sizer Sizer) (n int)
SizeMapEntry(number int32, entry EntrySize) (n int)
SizeListPacked(number int32, length int, single EntrySize) (n int)
Skip(buf []byte, _type int8, number int32) (n int, err error)
}
// Marshal .
type Marshal func(buf []byte, numTagOrKey, numIdxOrVal int32) int
// Unmarshal .
type Unmarshal func(buf []byte, _type int8) (n int, err error)
// EntrySize .
type EntrySize func(numTagOrKey, numIdxOrVal int32) int
// WriteMessage .
func WriteMessage(buf []byte, number int32, writer Writer) (n int) {
return Impl.WriteMessage(buf, number, writer)
}
// WriteListPacked .
func WriteListPacked(buf []byte, number int32, length int, single Marshal) (n int) {
return Impl.WriteListPacked(buf, number, length, single)
}
// WriteMapEntry .
func WriteMapEntry(buf []byte, number int32, entry Marshal) (n int) {
return Impl.WriteMapEntry(buf, number, entry)
}
// WriteBool .
func WriteBool(buf []byte, number int32, value bool) (n int) {
return Impl.WriteBool(buf, number, value)
}
// WriteInt32 .
func WriteInt32(buf []byte, number, value int32) (n int) {
return Impl.WriteInt32(buf, number, value)
}
// WriteInt64 .
func WriteInt64(buf []byte, number int32, value int64) (n int) {
return Impl.WriteInt64(buf, number, value)
}
// WriteUint32 .
func WriteUint32(buf []byte, number int32, value uint32) (n int) {
return Impl.WriteUint32(buf, number, value)
}
// WriteUint64 .
func WriteUint64(buf []byte, number int32, value uint64) (n int) {
return Impl.WriteUint64(buf, number, value)
}
// WriteSint32 .
func WriteSint32(buf []byte, number, value int32) (n int) {
return Impl.WriteSint32(buf, number, value)
}
// WriteSint64 .
func WriteSint64(buf []byte, number int32, value int64) (n int) {
return Impl.WriteSint64(buf, number, value)
}
// WriteFloat .
func WriteFloat(buf []byte, number int32, value float32) (n int) {
return Impl.WriteFloat(buf, number, value)
}
// WriteDouble .
func WriteDouble(buf []byte, number int32, value float64) (n int) {
return Impl.WriteDouble(buf, number, value)
}
// WriteFixed32 .
func WriteFixed32(buf []byte, number int32, value uint32) (n int) {
return Impl.WriteFixed32(buf, number, value)
}
// WriteFixed64 .
func WriteFixed64(buf []byte, number int32, value uint64) (n int) {
return Impl.WriteFixed64(buf, number, value)
}
// WriteSfixed32 .
func WriteSfixed32(buf []byte, number, value int32) (n int) {
return Impl.WriteSfixed32(buf, number, value)
}
// WriteSfixed64 .
func WriteSfixed64(buf []byte, number int32, value int64) (n int) {
return Impl.WriteSfixed64(buf, number, value)
}
// WriteString .
func WriteString(buf []byte, number int32, value string) (n int) {
return Impl.WriteString(buf, number, value)
}
// WriteBytes .
func WriteBytes(buf []byte, number int32, value []byte) (n int) {
return Impl.WriteBytes(buf, number, value)
}
// ReadMessage .
func ReadMessage(buf []byte, _type int8, reader Reader) (offset int, err error) {
return Impl.ReadMessage(buf, _type, reader)
}
// ReadList .
func ReadList(buf []byte, _type int8, single Unmarshal) (n int, err error) {
return Impl.ReadList(buf, _type, single)
}
// ReadMapEntry .
func ReadMapEntry(buf []byte, _type int8, umk, umv Unmarshal) (int, error) {
return Impl.ReadMapEntry(buf, _type, umk, umv)
}
// ReadBool .
func ReadBool(buf []byte, _type int8) (value bool, n int, err error) {
return Impl.ReadBool(buf, _type)
}
// ReadInt32 .
func ReadInt32(buf []byte, _type int8) (value int32, n int, err error) {
return Impl.ReadInt32(buf, _type)
}
// ReadInt64 .
func ReadInt64(buf []byte, _type int8) (value int64, n int, err error) {
return Impl.ReadInt64(buf, _type)
}
// ReadUint32 .
func ReadUint32(buf []byte, _type int8) (value uint32, n int, err error) {
return Impl.ReadUint32(buf, _type)
}
// ReadUint64 .
func ReadUint64(buf []byte, _type int8) (value uint64, n int, err error) {
return Impl.ReadUint64(buf, _type)
}
// ReadSint32 .
func ReadSint32(buf []byte, _type int8) (value int32, n int, err error) {
return Impl.ReadSint32(buf, _type)
}
// ReadSint64 .
func ReadSint64(buf []byte, _type int8) (value int64, n int, err error) {
return Impl.ReadSint64(buf, _type)
}
// ReadFloat .
func ReadFloat(buf []byte, _type int8) (value float32, n int, err error) {
return Impl.ReadFloat(buf, _type)
}
// ReadDouble .
func ReadDouble(buf []byte, _type int8) (value float64, n int, err error) {
return Impl.ReadDouble(buf, _type)
}
// ReadFixed32 .
func ReadFixed32(buf []byte, _type int8) (value uint32, n int, err error) {
return Impl.ReadFixed32(buf, _type)
}
// ReadFixed64 .
func ReadFixed64(buf []byte, _type int8) (value uint64, n int, err error) {
return Impl.ReadFixed64(buf, _type)
}
// ReadSfixed32 .
func ReadSfixed32(buf []byte, _type int8) (value int32, n int, err error) {
return Impl.ReadSfixed32(buf, _type)
}
// ReadSfixed64 .
func ReadSfixed64(buf []byte, _type int8) (value int64, n int, err error) {
return Impl.ReadSfixed64(buf, _type)
}
// ReadString .
func ReadString(buf []byte, _type int8) (value string, n int, err error) {
return Impl.ReadString(buf, _type)
}
// ReadBytes .
func ReadBytes(buf []byte, _type int8) (value []byte, n int, err error) {
return Impl.ReadBytes(buf, _type)
}
// SizeBool .
func SizeBool(number int32, value bool) (n int) {
return Impl.SizeBool(number, value)
}
// SizeInt32 .
func SizeInt32(number, value int32) (n int) {
return Impl.SizeInt32(number, value)
}
// SizeInt64 .
func SizeInt64(number int32, value int64) (n int) {
return Impl.SizeInt64(number, value)
}
// SizeUint32 .
func SizeUint32(number int32, value uint32) (n int) {
return Impl.SizeUint32(number, value)
}
// SizeUint64 .
func SizeUint64(number int32, value uint64) (n int) {
return Impl.SizeUint64(number, value)
}
// SizeSint32 .
func SizeSint32(number, value int32) (n int) {
return Impl.SizeSint32(number, value)
}
// SizeSint64 .
func SizeSint64(number int32, value int64) (n int) {
return Impl.SizeSint64(number, value)
}
// SizeFloat .
func SizeFloat(number int32, value float32) (n int) {
return Impl.SizeFloat(number, value)
}
// SizeDouble .
func SizeDouble(number int32, value float64) (n int) {
return Impl.SizeDouble(number, value)
}
// SizeFixed32 .
func SizeFixed32(number int32, value uint32) (n int) {
return Impl.SizeFixed32(number, value)
}
// SizeFixed64 .
func SizeFixed64(number int32, value uint64) (n int) {
return Impl.SizeFixed64(number, value)
}
// SizeSfixed32 .
func SizeSfixed32(number, value int32) (n int) {
return Impl.SizeSfixed32(number, value)
}
// SizeSfixed64 .
func SizeSfixed64(number int32, value int64) (n int) {
return Impl.SizeSfixed64(number, value)
}
// SizeString .
func SizeString(number int32, value string) (n int) {
return Impl.SizeString(number, value)
}
// SizeBytes .
func SizeBytes(number int32, value []byte) (n int) {
return Impl.SizeBytes(number, value)
}
// SizeMessage .
func SizeMessage(number int32, sizer Sizer) (n int) {
return Impl.SizeMessage(number, sizer)
}
// SizeMapEntry .
func SizeMapEntry(number int32, entry EntrySize) (n int) {
return Impl.SizeMapEntry(number, entry)
}
// SizeListPacked .
func SizeListPacked(number int32, length int, single EntrySize) (n int) {
return Impl.SizeListPacked(number, length, single)
}
// Skip .
func Skip(buf []byte, _type int8, number int32) (n int, err error) {
return Impl.Skip(buf, _type, number)
}