-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
tl_video_size_gen.go
317 lines (290 loc) · 6.66 KB
/
tl_video_size_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
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
// 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/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{}
)
// VideoSize represents TL type `videoSize#e831c556`.
// Animated profile picture¹ in MPEG4 format
//
// Links:
// 1) https://core.telegram.org/api/files#animated-profile-pictures
//
// See https://core.telegram.org/constructor/videoSize for reference.
type VideoSize struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// u for animated profile pictures, and v for trimmed and downscaled video previews
Type string
// File location
Location FileLocationToBeDeprecated
// Video width
W int
// Video height
H int
// File size
Size int
// Timestamp that should be shown as static preview to the user (seconds)
//
// Use SetVideoStartTs and GetVideoStartTs helpers.
VideoStartTs float64
}
// VideoSizeTypeID is TL type id of VideoSize.
const VideoSizeTypeID = 0xe831c556
func (v *VideoSize) Zero() bool {
if v == nil {
return true
}
if !(v.Flags.Zero()) {
return false
}
if !(v.Type == "") {
return false
}
if !(v.Location.Zero()) {
return false
}
if !(v.W == 0) {
return false
}
if !(v.H == 0) {
return false
}
if !(v.Size == 0) {
return false
}
if !(v.VideoStartTs == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (v *VideoSize) String() string {
if v == nil {
return "VideoSize(nil)"
}
type Alias VideoSize
return fmt.Sprintf("VideoSize%+v", Alias(*v))
}
// FillFrom fills VideoSize from given interface.
func (v *VideoSize) FillFrom(from interface {
GetType() (value string)
GetLocation() (value FileLocationToBeDeprecated)
GetW() (value int)
GetH() (value int)
GetSize() (value int)
GetVideoStartTs() (value float64, ok bool)
}) {
v.Type = from.GetType()
v.Location = from.GetLocation()
v.W = from.GetW()
v.H = from.GetH()
v.Size = from.GetSize()
if val, ok := from.GetVideoStartTs(); ok {
v.VideoStartTs = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*VideoSize) TypeID() uint32 {
return VideoSizeTypeID
}
// TypeName returns name of type in TL schema.
func (*VideoSize) TypeName() string {
return "videoSize"
}
// TypeInfo returns info about TL type.
func (v *VideoSize) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "videoSize",
ID: VideoSizeTypeID,
}
if v == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Type",
SchemaName: "type",
},
{
Name: "Location",
SchemaName: "location",
},
{
Name: "W",
SchemaName: "w",
},
{
Name: "H",
SchemaName: "h",
},
{
Name: "Size",
SchemaName: "size",
},
{
Name: "VideoStartTs",
SchemaName: "video_start_ts",
Null: !v.Flags.Has(0),
},
}
return typ
}
// Encode implements bin.Encoder.
func (v *VideoSize) Encode(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't encode videoSize#e831c556 as nil")
}
b.PutID(VideoSizeTypeID)
return v.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (v *VideoSize) EncodeBare(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't encode videoSize#e831c556 as nil")
}
if !(v.VideoStartTs == 0) {
v.Flags.Set(0)
}
if err := v.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode videoSize#e831c556: field flags: %w", err)
}
b.PutString(v.Type)
if err := v.Location.Encode(b); err != nil {
return fmt.Errorf("unable to encode videoSize#e831c556: field location: %w", err)
}
b.PutInt(v.W)
b.PutInt(v.H)
b.PutInt(v.Size)
if v.Flags.Has(0) {
b.PutDouble(v.VideoStartTs)
}
return nil
}
// GetType returns value of Type field.
func (v *VideoSize) GetType() (value string) {
return v.Type
}
// GetLocation returns value of Location field.
func (v *VideoSize) GetLocation() (value FileLocationToBeDeprecated) {
return v.Location
}
// GetW returns value of W field.
func (v *VideoSize) GetW() (value int) {
return v.W
}
// GetH returns value of H field.
func (v *VideoSize) GetH() (value int) {
return v.H
}
// GetSize returns value of Size field.
func (v *VideoSize) GetSize() (value int) {
return v.Size
}
// SetVideoStartTs sets value of VideoStartTs conditional field.
func (v *VideoSize) SetVideoStartTs(value float64) {
v.Flags.Set(0)
v.VideoStartTs = value
}
// GetVideoStartTs returns value of VideoStartTs conditional field and
// boolean which is true if field was set.
func (v *VideoSize) GetVideoStartTs() (value float64, ok bool) {
if !v.Flags.Has(0) {
return value, false
}
return v.VideoStartTs, true
}
// Decode implements bin.Decoder.
func (v *VideoSize) Decode(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't decode videoSize#e831c556 to nil")
}
if err := b.ConsumeID(VideoSizeTypeID); err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: %w", err)
}
return v.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (v *VideoSize) DecodeBare(b *bin.Buffer) error {
if v == nil {
return fmt.Errorf("can't decode videoSize#e831c556 to nil")
}
{
if err := v.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field flags: %w", err)
}
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field type: %w", err)
}
v.Type = value
}
{
if err := v.Location.Decode(b); err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field location: %w", err)
}
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field w: %w", err)
}
v.W = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field h: %w", err)
}
v.H = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field size: %w", err)
}
v.Size = value
}
if v.Flags.Has(0) {
value, err := b.Double()
if err != nil {
return fmt.Errorf("unable to decode videoSize#e831c556: field video_start_ts: %w", err)
}
v.VideoStartTs = value
}
return nil
}
// Ensuring interfaces in compile-time for VideoSize.
var (
_ bin.Encoder = &VideoSize{}
_ bin.Decoder = &VideoSize{}
_ bin.BareEncoder = &VideoSize{}
_ bin.BareDecoder = &VideoSize{}
)