-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
tl_nearest_dc_gen.go
207 lines (185 loc) · 4.22 KB
/
tl_nearest_dc_gen.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
// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// NearestDC represents TL type `nearestDc#8e1a1775`.
// Nearest data centre, according to geo-ip.
//
// See https://core.telegram.org/constructor/nearestDc for reference.
type NearestDC struct {
// Country code determined by geo-ip
Country string
// Number of current data centre
ThisDC int
// Number of nearest data centre
NearestDC int
}
// NearestDCTypeID is TL type id of NearestDC.
const NearestDCTypeID = 0x8e1a1775
// Ensuring interfaces in compile-time for NearestDC.
var (
_ bin.Encoder = &NearestDC{}
_ bin.Decoder = &NearestDC{}
_ bin.BareEncoder = &NearestDC{}
_ bin.BareDecoder = &NearestDC{}
)
func (n *NearestDC) Zero() bool {
if n == nil {
return true
}
if !(n.Country == "") {
return false
}
if !(n.ThisDC == 0) {
return false
}
if !(n.NearestDC == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (n *NearestDC) String() string {
if n == nil {
return "NearestDC(nil)"
}
type Alias NearestDC
return fmt.Sprintf("NearestDC%+v", Alias(*n))
}
// FillFrom fills NearestDC from given interface.
func (n *NearestDC) FillFrom(from interface {
GetCountry() (value string)
GetThisDC() (value int)
GetNearestDC() (value int)
}) {
n.Country = from.GetCountry()
n.ThisDC = from.GetThisDC()
n.NearestDC = from.GetNearestDC()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*NearestDC) TypeID() uint32 {
return NearestDCTypeID
}
// TypeName returns name of type in TL schema.
func (*NearestDC) TypeName() string {
return "nearestDc"
}
// TypeInfo returns info about TL type.
func (n *NearestDC) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "nearestDc",
ID: NearestDCTypeID,
}
if n == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Country",
SchemaName: "country",
},
{
Name: "ThisDC",
SchemaName: "this_dc",
},
{
Name: "NearestDC",
SchemaName: "nearest_dc",
},
}
return typ
}
// Encode implements bin.Encoder.
func (n *NearestDC) Encode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode nearestDc#8e1a1775 as nil")
}
b.PutID(NearestDCTypeID)
return n.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (n *NearestDC) EncodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't encode nearestDc#8e1a1775 as nil")
}
b.PutString(n.Country)
b.PutInt(n.ThisDC)
b.PutInt(n.NearestDC)
return nil
}
// Decode implements bin.Decoder.
func (n *NearestDC) Decode(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode nearestDc#8e1a1775 to nil")
}
if err := b.ConsumeID(NearestDCTypeID); err != nil {
return fmt.Errorf("unable to decode nearestDc#8e1a1775: %w", err)
}
return n.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (n *NearestDC) DecodeBare(b *bin.Buffer) error {
if n == nil {
return fmt.Errorf("can't decode nearestDc#8e1a1775 to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode nearestDc#8e1a1775: field country: %w", err)
}
n.Country = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode nearestDc#8e1a1775: field this_dc: %w", err)
}
n.ThisDC = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode nearestDc#8e1a1775: field nearest_dc: %w", err)
}
n.NearestDC = value
}
return nil
}
// GetCountry returns value of Country field.
func (n *NearestDC) GetCountry() (value string) {
return n.Country
}
// GetThisDC returns value of ThisDC field.
func (n *NearestDC) GetThisDC() (value int) {
return n.ThisDC
}
// GetNearestDC returns value of NearestDC field.
func (n *NearestDC) GetNearestDC() (value int) {
return n.NearestDC
}