-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
tl_photo_size_gen.go
735 lines (666 loc) · 15.7 KB
/
tl_photo_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
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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
// Code generated by gotdgen, DO NOT EDIT.
package e2e
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{}
)
// PhotoSizeEmpty represents TL type `photoSizeEmpty#e17e23c`.
// Empty constructor. Image with this thumbnail is unavailable.
//
// See https://core.telegram.org/constructor/photoSizeEmpty for reference.
type PhotoSizeEmpty struct {
// Thumbnail type »¹
//
// Links:
// 1) https://core.telegram.org/api/files#image-thumbnail-types
Type string
}
// PhotoSizeEmptyTypeID is TL type id of PhotoSizeEmpty.
const PhotoSizeEmptyTypeID = 0xe17e23c
// construct implements constructor of PhotoSizeClass.
func (p PhotoSizeEmpty) construct() PhotoSizeClass { return &p }
// Ensuring interfaces in compile-time for PhotoSizeEmpty.
var (
_ bin.Encoder = &PhotoSizeEmpty{}
_ bin.Decoder = &PhotoSizeEmpty{}
_ bin.BareEncoder = &PhotoSizeEmpty{}
_ bin.BareDecoder = &PhotoSizeEmpty{}
_ PhotoSizeClass = &PhotoSizeEmpty{}
)
func (p *PhotoSizeEmpty) Zero() bool {
if p == nil {
return true
}
if !(p.Type == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhotoSizeEmpty) String() string {
if p == nil {
return "PhotoSizeEmpty(nil)"
}
type Alias PhotoSizeEmpty
return fmt.Sprintf("PhotoSizeEmpty%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhotoSizeEmpty) TypeID() uint32 {
return PhotoSizeEmptyTypeID
}
// TypeName returns name of type in TL schema.
func (*PhotoSizeEmpty) TypeName() string {
return "photoSizeEmpty"
}
// TypeInfo returns info about TL type.
func (p *PhotoSizeEmpty) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "photoSizeEmpty",
ID: PhotoSizeEmptyTypeID,
}
if p == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Type",
SchemaName: "type",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PhotoSizeEmpty) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoSizeEmpty#e17e23c as nil")
}
b.PutID(PhotoSizeEmptyTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhotoSizeEmpty) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoSizeEmpty#e17e23c as nil")
}
b.PutString(p.Type)
return nil
}
// Decode implements bin.Decoder.
func (p *PhotoSizeEmpty) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoSizeEmpty#e17e23c to nil")
}
if err := b.ConsumeID(PhotoSizeEmptyTypeID); err != nil {
return fmt.Errorf("unable to decode photoSizeEmpty#e17e23c: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhotoSizeEmpty) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoSizeEmpty#e17e23c to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode photoSizeEmpty#e17e23c: field type: %w", err)
}
p.Type = value
}
return nil
}
// GetType returns value of Type field.
func (p *PhotoSizeEmpty) GetType() (value string) {
if p == nil {
return
}
return p.Type
}
// PhotoSize represents TL type `photoSize#77bfb61b`.
// Image description.
//
// See https://core.telegram.org/constructor/photoSize for reference.
type PhotoSize struct {
// Thumbnail type »¹
//
// Links:
// 1) https://core.telegram.org/api/files#image-thumbnail-types
Type string
// Location field of PhotoSize.
Location FileLocationClass
// Image width
W int
// Image height
H int
// File size
Size int
}
// PhotoSizeTypeID is TL type id of PhotoSize.
const PhotoSizeTypeID = 0x77bfb61b
// construct implements constructor of PhotoSizeClass.
func (p PhotoSize) construct() PhotoSizeClass { return &p }
// Ensuring interfaces in compile-time for PhotoSize.
var (
_ bin.Encoder = &PhotoSize{}
_ bin.Decoder = &PhotoSize{}
_ bin.BareEncoder = &PhotoSize{}
_ bin.BareDecoder = &PhotoSize{}
_ PhotoSizeClass = &PhotoSize{}
)
func (p *PhotoSize) Zero() bool {
if p == nil {
return true
}
if !(p.Type == "") {
return false
}
if !(p.Location == nil) {
return false
}
if !(p.W == 0) {
return false
}
if !(p.H == 0) {
return false
}
if !(p.Size == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhotoSize) String() string {
if p == nil {
return "PhotoSize(nil)"
}
type Alias PhotoSize
return fmt.Sprintf("PhotoSize%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhotoSize) TypeID() uint32 {
return PhotoSizeTypeID
}
// TypeName returns name of type in TL schema.
func (*PhotoSize) TypeName() string {
return "photoSize"
}
// TypeInfo returns info about TL type.
func (p *PhotoSize) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "photoSize",
ID: PhotoSizeTypeID,
}
if p == 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",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PhotoSize) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoSize#77bfb61b as nil")
}
b.PutID(PhotoSizeTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhotoSize) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoSize#77bfb61b as nil")
}
b.PutString(p.Type)
if p.Location == nil {
return fmt.Errorf("unable to encode photoSize#77bfb61b: field location is nil")
}
if err := p.Location.Encode(b); err != nil {
return fmt.Errorf("unable to encode photoSize#77bfb61b: field location: %w", err)
}
b.PutInt(p.W)
b.PutInt(p.H)
b.PutInt(p.Size)
return nil
}
// Decode implements bin.Decoder.
func (p *PhotoSize) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoSize#77bfb61b to nil")
}
if err := b.ConsumeID(PhotoSizeTypeID); err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhotoSize) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoSize#77bfb61b to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: field type: %w", err)
}
p.Type = value
}
{
value, err := DecodeFileLocation(b)
if err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: field location: %w", err)
}
p.Location = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: field w: %w", err)
}
p.W = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: field h: %w", err)
}
p.H = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photoSize#77bfb61b: field size: %w", err)
}
p.Size = value
}
return nil
}
// GetType returns value of Type field.
func (p *PhotoSize) GetType() (value string) {
if p == nil {
return
}
return p.Type
}
// GetLocation returns value of Location field.
func (p *PhotoSize) GetLocation() (value FileLocationClass) {
if p == nil {
return
}
return p.Location
}
// GetW returns value of W field.
func (p *PhotoSize) GetW() (value int) {
if p == nil {
return
}
return p.W
}
// GetH returns value of H field.
func (p *PhotoSize) GetH() (value int) {
if p == nil {
return
}
return p.H
}
// GetSize returns value of Size field.
func (p *PhotoSize) GetSize() (value int) {
if p == nil {
return
}
return p.Size
}
// PhotoCachedSize represents TL type `photoCachedSize#e9a734fa`.
// Description of an image and its content.
//
// See https://core.telegram.org/constructor/photoCachedSize for reference.
type PhotoCachedSize struct {
// Thumbnail type
Type string
// Location field of PhotoCachedSize.
Location FileLocationClass
// Image width
W int
// Image height
H int
// Binary data, file content
Bytes []byte
}
// PhotoCachedSizeTypeID is TL type id of PhotoCachedSize.
const PhotoCachedSizeTypeID = 0xe9a734fa
// construct implements constructor of PhotoSizeClass.
func (p PhotoCachedSize) construct() PhotoSizeClass { return &p }
// Ensuring interfaces in compile-time for PhotoCachedSize.
var (
_ bin.Encoder = &PhotoCachedSize{}
_ bin.Decoder = &PhotoCachedSize{}
_ bin.BareEncoder = &PhotoCachedSize{}
_ bin.BareDecoder = &PhotoCachedSize{}
_ PhotoSizeClass = &PhotoCachedSize{}
)
func (p *PhotoCachedSize) Zero() bool {
if p == nil {
return true
}
if !(p.Type == "") {
return false
}
if !(p.Location == nil) {
return false
}
if !(p.W == 0) {
return false
}
if !(p.H == 0) {
return false
}
if !(p.Bytes == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (p *PhotoCachedSize) String() string {
if p == nil {
return "PhotoCachedSize(nil)"
}
type Alias PhotoCachedSize
return fmt.Sprintf("PhotoCachedSize%+v", Alias(*p))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*PhotoCachedSize) TypeID() uint32 {
return PhotoCachedSizeTypeID
}
// TypeName returns name of type in TL schema.
func (*PhotoCachedSize) TypeName() string {
return "photoCachedSize"
}
// TypeInfo returns info about TL type.
func (p *PhotoCachedSize) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "photoCachedSize",
ID: PhotoCachedSizeTypeID,
}
if p == 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: "Bytes",
SchemaName: "bytes",
},
}
return typ
}
// Encode implements bin.Encoder.
func (p *PhotoCachedSize) Encode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoCachedSize#e9a734fa as nil")
}
b.PutID(PhotoCachedSizeTypeID)
return p.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (p *PhotoCachedSize) EncodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't encode photoCachedSize#e9a734fa as nil")
}
b.PutString(p.Type)
if p.Location == nil {
return fmt.Errorf("unable to encode photoCachedSize#e9a734fa: field location is nil")
}
if err := p.Location.Encode(b); err != nil {
return fmt.Errorf("unable to encode photoCachedSize#e9a734fa: field location: %w", err)
}
b.PutInt(p.W)
b.PutInt(p.H)
b.PutBytes(p.Bytes)
return nil
}
// Decode implements bin.Decoder.
func (p *PhotoCachedSize) Decode(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoCachedSize#e9a734fa to nil")
}
if err := b.ConsumeID(PhotoCachedSizeTypeID); err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: %w", err)
}
return p.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (p *PhotoCachedSize) DecodeBare(b *bin.Buffer) error {
if p == nil {
return fmt.Errorf("can't decode photoCachedSize#e9a734fa to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: field type: %w", err)
}
p.Type = value
}
{
value, err := DecodeFileLocation(b)
if err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: field location: %w", err)
}
p.Location = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: field w: %w", err)
}
p.W = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: field h: %w", err)
}
p.H = value
}
{
value, err := b.Bytes()
if err != nil {
return fmt.Errorf("unable to decode photoCachedSize#e9a734fa: field bytes: %w", err)
}
p.Bytes = value
}
return nil
}
// GetType returns value of Type field.
func (p *PhotoCachedSize) GetType() (value string) {
if p == nil {
return
}
return p.Type
}
// GetLocation returns value of Location field.
func (p *PhotoCachedSize) GetLocation() (value FileLocationClass) {
if p == nil {
return
}
return p.Location
}
// GetW returns value of W field.
func (p *PhotoCachedSize) GetW() (value int) {
if p == nil {
return
}
return p.W
}
// GetH returns value of H field.
func (p *PhotoCachedSize) GetH() (value int) {
if p == nil {
return
}
return p.H
}
// GetBytes returns value of Bytes field.
func (p *PhotoCachedSize) GetBytes() (value []byte) {
if p == nil {
return
}
return p.Bytes
}
// PhotoSizeClassName is schema name of PhotoSizeClass.
const PhotoSizeClassName = "PhotoSize"
// PhotoSizeClass represents PhotoSize generic type.
//
// See https://core.telegram.org/type/PhotoSize for reference.
//
// Example:
//
// g, err := e2e.DecodePhotoSize(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *e2e.PhotoSizeEmpty: // photoSizeEmpty#e17e23c
// case *e2e.PhotoSize: // photoSize#77bfb61b
// case *e2e.PhotoCachedSize: // photoCachedSize#e9a734fa
// default: panic(v)
// }
type PhotoSizeClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() PhotoSizeClass
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
TypeID() uint32
// TypeName returns name of type in TL schema.
TypeName() string
// String implements fmt.Stringer.
String() string
// Zero returns true if current object has a zero value.
Zero() bool
// Thumbnail type »¹
//
// Links:
// 1) https://core.telegram.org/api/files#image-thumbnail-types
GetType() (value string)
}
// DecodePhotoSize implements binary de-serialization for PhotoSizeClass.
func DecodePhotoSize(buf *bin.Buffer) (PhotoSizeClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case PhotoSizeEmptyTypeID:
// Decoding photoSizeEmpty#e17e23c.
v := PhotoSizeEmpty{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhotoSizeClass: %w", err)
}
return &v, nil
case PhotoSizeTypeID:
// Decoding photoSize#77bfb61b.
v := PhotoSize{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhotoSizeClass: %w", err)
}
return &v, nil
case PhotoCachedSizeTypeID:
// Decoding photoCachedSize#e9a734fa.
v := PhotoCachedSize{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode PhotoSizeClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode PhotoSizeClass: %w", bin.NewUnexpectedID(id))
}
}
// PhotoSize boxes the PhotoSizeClass providing a helper.
type PhotoSizeBox struct {
PhotoSize PhotoSizeClass
}
// Decode implements bin.Decoder for PhotoSizeBox.
func (b *PhotoSizeBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode PhotoSizeBox to nil")
}
v, err := DecodePhotoSize(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.PhotoSize = v
return nil
}
// Encode implements bin.Encode for PhotoSizeBox.
func (b *PhotoSizeBox) Encode(buf *bin.Buffer) error {
if b == nil || b.PhotoSize == nil {
return fmt.Errorf("unable to encode PhotoSizeClass as nil")
}
return b.PhotoSize.Encode(buf)
}