generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 8
/
user.pb.fast.go
103 lines (90 loc) · 2.02 KB
/
user.pb.fast.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
// Code generated by Fastpb v0.0.2. DO NOT EDIT.
package user
import (
fmt "fmt"
fastpb "github.com/cloudwego/fastpb"
)
var (
_ = fmt.Errorf
_ = fastpb.Skip
)
func (x *User) FastRead(buf []byte, _type int8, number int32) (offset int, err error) {
switch number {
case 1:
offset, err = x.fastReadField1(buf, _type)
if err != nil {
goto ReadFieldError
}
case 2:
offset, err = x.fastReadField2(buf, _type)
if err != nil {
goto ReadFieldError
}
default:
offset, err = fastpb.Skip(buf, _type, number)
if err != nil {
goto SkipFieldError
}
}
return offset, nil
SkipFieldError:
return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err)
ReadFieldError:
return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_User[number], err)
}
func (x *User) fastReadField1(buf []byte, _type int8) (offset int, err error) {
x.Id, offset, err = fastpb.ReadInt32(buf, _type)
return offset, err
}
func (x *User) fastReadField2(buf []byte, _type int8) (offset int, err error) {
x.Name, offset, err = fastpb.ReadString(buf, _type)
return offset, err
}
func (x *User) FastWrite(buf []byte) (offset int) {
if x == nil {
return offset
}
offset += x.fastWriteField1(buf[offset:])
offset += x.fastWriteField2(buf[offset:])
return offset
}
func (x *User) fastWriteField1(buf []byte) (offset int) {
if x.Id == 0 {
return offset
}
offset += fastpb.WriteInt32(buf[offset:], 1, x.Id)
return offset
}
func (x *User) fastWriteField2(buf []byte) (offset int) {
if x.Name == "" {
return offset
}
offset += fastpb.WriteString(buf[offset:], 2, x.Name)
return offset
}
func (x *User) Size() (n int) {
if x == nil {
return n
}
n += x.sizeField1()
n += x.sizeField2()
return n
}
func (x *User) sizeField1() (n int) {
if x.Id == 0 {
return n
}
n += fastpb.SizeInt32(1, x.Id)
return n
}
func (x *User) sizeField2() (n int) {
if x.Name == "" {
return n
}
n += fastpb.SizeString(2, x.Name)
return n
}
var fieldIDToName_User = map[int32]string{
1: "Id",
2: "Name",
}