-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
tl_messages_exported_chat_invite_gen.go
767 lines (669 loc) · 21.7 KB
/
tl_messages_exported_chat_invite_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
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
// 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{}
)
// MessagesExportedChatInvite represents TL type `messages.exportedChatInvite#1871be50`.
//
// See https://core.telegram.org/constructor/messages.exportedChatInvite for reference.
type MessagesExportedChatInvite struct {
// Invite field of MessagesExportedChatInvite.
Invite ChatInviteExported
// Users field of MessagesExportedChatInvite.
Users []UserClass
}
// MessagesExportedChatInviteTypeID is TL type id of MessagesExportedChatInvite.
const MessagesExportedChatInviteTypeID = 0x1871be50
func (e *MessagesExportedChatInvite) Zero() bool {
if e == nil {
return true
}
if !(e.Invite.Zero()) {
return false
}
if !(e.Users == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (e *MessagesExportedChatInvite) String() string {
if e == nil {
return "MessagesExportedChatInvite(nil)"
}
type Alias MessagesExportedChatInvite
return fmt.Sprintf("MessagesExportedChatInvite%+v", Alias(*e))
}
// FillFrom fills MessagesExportedChatInvite from given interface.
func (e *MessagesExportedChatInvite) FillFrom(from interface {
GetInvite() (value ChatInviteExported)
GetUsers() (value []UserClass)
}) {
e.Invite = from.GetInvite()
e.Users = from.GetUsers()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessagesExportedChatInvite) TypeID() uint32 {
return MessagesExportedChatInviteTypeID
}
// TypeName returns name of type in TL schema.
func (*MessagesExportedChatInvite) TypeName() string {
return "messages.exportedChatInvite"
}
// TypeInfo returns info about TL type.
func (e *MessagesExportedChatInvite) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "messages.exportedChatInvite",
ID: MessagesExportedChatInviteTypeID,
}
if e == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Invite",
SchemaName: "invite",
},
{
Name: "Users",
SchemaName: "users",
},
}
return typ
}
// Encode implements bin.Encoder.
func (e *MessagesExportedChatInvite) Encode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode messages.exportedChatInvite#1871be50 as nil")
}
b.PutID(MessagesExportedChatInviteTypeID)
return e.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (e *MessagesExportedChatInvite) EncodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode messages.exportedChatInvite#1871be50 as nil")
}
if err := e.Invite.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field invite: %w", err)
}
b.PutVectorHeader(len(e.Users))
for idx, v := range e.Users {
if v == nil {
return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.exportedChatInvite#1871be50: field users element with index %d: %w", idx, err)
}
}
return nil
}
// GetInvite returns value of Invite field.
func (e *MessagesExportedChatInvite) GetInvite() (value ChatInviteExported) {
return e.Invite
}
// GetUsers returns value of Users field.
func (e *MessagesExportedChatInvite) GetUsers() (value []UserClass) {
return e.Users
}
// MapUsers returns field Users wrapped in UserClassArray helper.
func (e *MessagesExportedChatInvite) MapUsers() (value UserClassArray) {
return UserClassArray(e.Users)
}
// Decode implements bin.Decoder.
func (e *MessagesExportedChatInvite) Decode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode messages.exportedChatInvite#1871be50 to nil")
}
if err := b.ConsumeID(MessagesExportedChatInviteTypeID); err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: %w", err)
}
return e.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (e *MessagesExportedChatInvite) DecodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode messages.exportedChatInvite#1871be50 to nil")
}
{
if err := e.Invite.Decode(b); err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field invite: %w", err)
}
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field users: %w", err)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeUser(b)
if err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInvite#1871be50: field users: %w", err)
}
e.Users = append(e.Users, value)
}
}
return nil
}
// construct implements constructor of MessagesExportedChatInviteClass.
func (e MessagesExportedChatInvite) construct() MessagesExportedChatInviteClass { return &e }
// Ensuring interfaces in compile-time for MessagesExportedChatInvite.
var (
_ bin.Encoder = &MessagesExportedChatInvite{}
_ bin.Decoder = &MessagesExportedChatInvite{}
_ bin.BareEncoder = &MessagesExportedChatInvite{}
_ bin.BareDecoder = &MessagesExportedChatInvite{}
_ MessagesExportedChatInviteClass = &MessagesExportedChatInvite{}
)
// MessagesExportedChatInviteReplaced represents TL type `messages.exportedChatInviteReplaced#222600ef`.
//
// See https://core.telegram.org/constructor/messages.exportedChatInviteReplaced for reference.
type MessagesExportedChatInviteReplaced struct {
// Invite field of MessagesExportedChatInviteReplaced.
Invite ChatInviteExported
// NewInvite field of MessagesExportedChatInviteReplaced.
NewInvite ChatInviteExported
// Users field of MessagesExportedChatInviteReplaced.
Users []UserClass
}
// MessagesExportedChatInviteReplacedTypeID is TL type id of MessagesExportedChatInviteReplaced.
const MessagesExportedChatInviteReplacedTypeID = 0x222600ef
func (e *MessagesExportedChatInviteReplaced) Zero() bool {
if e == nil {
return true
}
if !(e.Invite.Zero()) {
return false
}
if !(e.NewInvite.Zero()) {
return false
}
if !(e.Users == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (e *MessagesExportedChatInviteReplaced) String() string {
if e == nil {
return "MessagesExportedChatInviteReplaced(nil)"
}
type Alias MessagesExportedChatInviteReplaced
return fmt.Sprintf("MessagesExportedChatInviteReplaced%+v", Alias(*e))
}
// FillFrom fills MessagesExportedChatInviteReplaced from given interface.
func (e *MessagesExportedChatInviteReplaced) FillFrom(from interface {
GetInvite() (value ChatInviteExported)
GetNewInvite() (value ChatInviteExported)
GetUsers() (value []UserClass)
}) {
e.Invite = from.GetInvite()
e.NewInvite = from.GetNewInvite()
e.Users = from.GetUsers()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*MessagesExportedChatInviteReplaced) TypeID() uint32 {
return MessagesExportedChatInviteReplacedTypeID
}
// TypeName returns name of type in TL schema.
func (*MessagesExportedChatInviteReplaced) TypeName() string {
return "messages.exportedChatInviteReplaced"
}
// TypeInfo returns info about TL type.
func (e *MessagesExportedChatInviteReplaced) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "messages.exportedChatInviteReplaced",
ID: MessagesExportedChatInviteReplacedTypeID,
}
if e == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Invite",
SchemaName: "invite",
},
{
Name: "NewInvite",
SchemaName: "new_invite",
},
{
Name: "Users",
SchemaName: "users",
},
}
return typ
}
// Encode implements bin.Encoder.
func (e *MessagesExportedChatInviteReplaced) Encode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode messages.exportedChatInviteReplaced#222600ef as nil")
}
b.PutID(MessagesExportedChatInviteReplacedTypeID)
return e.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (e *MessagesExportedChatInviteReplaced) EncodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't encode messages.exportedChatInviteReplaced#222600ef as nil")
}
if err := e.Invite.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field invite: %w", err)
}
if err := e.NewInvite.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w", err)
}
b.PutVectorHeader(len(e.Users))
for idx, v := range e.Users {
if v == nil {
return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode messages.exportedChatInviteReplaced#222600ef: field users element with index %d: %w", idx, err)
}
}
return nil
}
// GetInvite returns value of Invite field.
func (e *MessagesExportedChatInviteReplaced) GetInvite() (value ChatInviteExported) {
return e.Invite
}
// GetNewInvite returns value of NewInvite field.
func (e *MessagesExportedChatInviteReplaced) GetNewInvite() (value ChatInviteExported) {
return e.NewInvite
}
// GetUsers returns value of Users field.
func (e *MessagesExportedChatInviteReplaced) GetUsers() (value []UserClass) {
return e.Users
}
// MapUsers returns field Users wrapped in UserClassArray helper.
func (e *MessagesExportedChatInviteReplaced) MapUsers() (value UserClassArray) {
return UserClassArray(e.Users)
}
// Decode implements bin.Decoder.
func (e *MessagesExportedChatInviteReplaced) Decode(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode messages.exportedChatInviteReplaced#222600ef to nil")
}
if err := b.ConsumeID(MessagesExportedChatInviteReplacedTypeID); err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: %w", err)
}
return e.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (e *MessagesExportedChatInviteReplaced) DecodeBare(b *bin.Buffer) error {
if e == nil {
return fmt.Errorf("can't decode messages.exportedChatInviteReplaced#222600ef to nil")
}
{
if err := e.Invite.Decode(b); err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field invite: %w", err)
}
}
{
if err := e.NewInvite.Decode(b); err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field new_invite: %w", err)
}
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field users: %w", err)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeUser(b)
if err != nil {
return fmt.Errorf("unable to decode messages.exportedChatInviteReplaced#222600ef: field users: %w", err)
}
e.Users = append(e.Users, value)
}
}
return nil
}
// construct implements constructor of MessagesExportedChatInviteClass.
func (e MessagesExportedChatInviteReplaced) construct() MessagesExportedChatInviteClass { return &e }
// Ensuring interfaces in compile-time for MessagesExportedChatInviteReplaced.
var (
_ bin.Encoder = &MessagesExportedChatInviteReplaced{}
_ bin.Decoder = &MessagesExportedChatInviteReplaced{}
_ bin.BareEncoder = &MessagesExportedChatInviteReplaced{}
_ bin.BareDecoder = &MessagesExportedChatInviteReplaced{}
_ MessagesExportedChatInviteClass = &MessagesExportedChatInviteReplaced{}
)
// MessagesExportedChatInviteClass represents messages.ExportedChatInvite generic type.
//
// See https://core.telegram.org/type/messages.ExportedChatInvite for reference.
//
// Example:
// g, err := tg.DecodeMessagesExportedChatInvite(buf)
// if err != nil {
// panic(err)
// }
// switch v := g.(type) {
// case *tg.MessagesExportedChatInvite: // messages.exportedChatInvite#1871be50
// case *tg.MessagesExportedChatInviteReplaced: // messages.exportedChatInviteReplaced#222600ef
// default: panic(v)
// }
type MessagesExportedChatInviteClass interface {
bin.Encoder
bin.Decoder
bin.BareEncoder
bin.BareDecoder
construct() MessagesExportedChatInviteClass
// 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
// Invite field of MessagesExportedChatInvite.
GetInvite() (value ChatInviteExported)
// Users field of MessagesExportedChatInvite.
GetUsers() (value []UserClass)
// Users field of MessagesExportedChatInvite.
MapUsers() (value UserClassArray)
}
// DecodeMessagesExportedChatInvite implements binary de-serialization for MessagesExportedChatInviteClass.
func DecodeMessagesExportedChatInvite(buf *bin.Buffer) (MessagesExportedChatInviteClass, error) {
id, err := buf.PeekID()
if err != nil {
return nil, err
}
switch id {
case MessagesExportedChatInviteTypeID:
// Decoding messages.exportedChatInvite#1871be50.
v := MessagesExportedChatInvite{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", err)
}
return &v, nil
case MessagesExportedChatInviteReplacedTypeID:
// Decoding messages.exportedChatInviteReplaced#222600ef.
v := MessagesExportedChatInviteReplaced{}
if err := v.Decode(buf); err != nil {
return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", err)
}
return &v, nil
default:
return nil, fmt.Errorf("unable to decode MessagesExportedChatInviteClass: %w", bin.NewUnexpectedID(id))
}
}
// MessagesExportedChatInvite boxes the MessagesExportedChatInviteClass providing a helper.
type MessagesExportedChatInviteBox struct {
ExportedChatInvite MessagesExportedChatInviteClass
}
// Decode implements bin.Decoder for MessagesExportedChatInviteBox.
func (b *MessagesExportedChatInviteBox) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("unable to decode MessagesExportedChatInviteBox to nil")
}
v, err := DecodeMessagesExportedChatInvite(buf)
if err != nil {
return fmt.Errorf("unable to decode boxed value: %w", err)
}
b.ExportedChatInvite = v
return nil
}
// Encode implements bin.Encode for MessagesExportedChatInviteBox.
func (b *MessagesExportedChatInviteBox) Encode(buf *bin.Buffer) error {
if b == nil || b.ExportedChatInvite == nil {
return fmt.Errorf("unable to encode MessagesExportedChatInviteClass as nil")
}
return b.ExportedChatInvite.Encode(buf)
}
// MessagesExportedChatInviteClassArray is adapter for slice of MessagesExportedChatInviteClass.
type MessagesExportedChatInviteClassArray []MessagesExportedChatInviteClass
// Sort sorts slice of MessagesExportedChatInviteClass.
func (s MessagesExportedChatInviteClassArray) Sort(less func(a, b MessagesExportedChatInviteClass) bool) MessagesExportedChatInviteClassArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of MessagesExportedChatInviteClass.
func (s MessagesExportedChatInviteClassArray) SortStable(less func(a, b MessagesExportedChatInviteClass) bool) MessagesExportedChatInviteClassArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of MessagesExportedChatInviteClass.
func (s MessagesExportedChatInviteClassArray) Retain(keep func(x MessagesExportedChatInviteClass) bool) MessagesExportedChatInviteClassArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s MessagesExportedChatInviteClassArray) First() (v MessagesExportedChatInviteClass, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s MessagesExportedChatInviteClassArray) Last() (v MessagesExportedChatInviteClass, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteClassArray) PopFirst() (v MessagesExportedChatInviteClass, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero MessagesExportedChatInviteClass
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteClassArray) Pop() (v MessagesExportedChatInviteClass, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// AsMessagesExportedChatInvite returns copy with only MessagesExportedChatInvite constructors.
func (s MessagesExportedChatInviteClassArray) AsMessagesExportedChatInvite() (to MessagesExportedChatInviteArray) {
for _, elem := range s {
value, ok := elem.(*MessagesExportedChatInvite)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// AsMessagesExportedChatInviteReplaced returns copy with only MessagesExportedChatInviteReplaced constructors.
func (s MessagesExportedChatInviteClassArray) AsMessagesExportedChatInviteReplaced() (to MessagesExportedChatInviteReplacedArray) {
for _, elem := range s {
value, ok := elem.(*MessagesExportedChatInviteReplaced)
if !ok {
continue
}
to = append(to, *value)
}
return to
}
// MessagesExportedChatInviteArray is adapter for slice of MessagesExportedChatInvite.
type MessagesExportedChatInviteArray []MessagesExportedChatInvite
// Sort sorts slice of MessagesExportedChatInvite.
func (s MessagesExportedChatInviteArray) Sort(less func(a, b MessagesExportedChatInvite) bool) MessagesExportedChatInviteArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of MessagesExportedChatInvite.
func (s MessagesExportedChatInviteArray) SortStable(less func(a, b MessagesExportedChatInvite) bool) MessagesExportedChatInviteArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of MessagesExportedChatInvite.
func (s MessagesExportedChatInviteArray) Retain(keep func(x MessagesExportedChatInvite) bool) MessagesExportedChatInviteArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s MessagesExportedChatInviteArray) First() (v MessagesExportedChatInvite, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s MessagesExportedChatInviteArray) Last() (v MessagesExportedChatInvite, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteArray) PopFirst() (v MessagesExportedChatInvite, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero MessagesExportedChatInvite
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteArray) Pop() (v MessagesExportedChatInvite, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}
// MessagesExportedChatInviteReplacedArray is adapter for slice of MessagesExportedChatInviteReplaced.
type MessagesExportedChatInviteReplacedArray []MessagesExportedChatInviteReplaced
// Sort sorts slice of MessagesExportedChatInviteReplaced.
func (s MessagesExportedChatInviteReplacedArray) Sort(less func(a, b MessagesExportedChatInviteReplaced) bool) MessagesExportedChatInviteReplacedArray {
sort.Slice(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// SortStable sorts slice of MessagesExportedChatInviteReplaced.
func (s MessagesExportedChatInviteReplacedArray) SortStable(less func(a, b MessagesExportedChatInviteReplaced) bool) MessagesExportedChatInviteReplacedArray {
sort.SliceStable(s, func(i, j int) bool {
return less(s[i], s[j])
})
return s
}
// Retain filters in-place slice of MessagesExportedChatInviteReplaced.
func (s MessagesExportedChatInviteReplacedArray) Retain(keep func(x MessagesExportedChatInviteReplaced) bool) MessagesExportedChatInviteReplacedArray {
n := 0
for _, x := range s {
if keep(x) {
s[n] = x
n++
}
}
s = s[:n]
return s
}
// First returns first element of slice (if exists).
func (s MessagesExportedChatInviteReplacedArray) First() (v MessagesExportedChatInviteReplaced, ok bool) {
if len(s) < 1 {
return
}
return s[0], true
}
// Last returns last element of slice (if exists).
func (s MessagesExportedChatInviteReplacedArray) Last() (v MessagesExportedChatInviteReplaced, ok bool) {
if len(s) < 1 {
return
}
return s[len(s)-1], true
}
// PopFirst returns first element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteReplacedArray) PopFirst() (v MessagesExportedChatInviteReplaced, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[0]
// Delete by index from SliceTricks.
copy(a[0:], a[1:])
var zero MessagesExportedChatInviteReplaced
a[len(a)-1] = zero
a = a[:len(a)-1]
*s = a
return v, true
}
// Pop returns last element of slice (if exists) and deletes it.
func (s *MessagesExportedChatInviteReplacedArray) Pop() (v MessagesExportedChatInviteReplaced, ok bool) {
if s == nil || len(*s) < 1 {
return
}
a := *s
v = a[len(a)-1]
a = a[:len(a)-1]
*s = a
return v, true
}