Files
mautrix-telegram/pkg/gotd/tdapi/tl_chat_folder_invite_links_gen.go
T
2025-06-27 20:03:37 -07:00

222 lines
5.7 KiB
Go

// Code generated by gotdgen, DO NOT EDIT.
package tdapi
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/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{}
)
// ChatFolderInviteLinks represents TL type `chatFolderInviteLinks#6c135313`.
type ChatFolderInviteLinks struct {
// List of the invite links
InviteLinks []ChatFolderInviteLink
}
// ChatFolderInviteLinksTypeID is TL type id of ChatFolderInviteLinks.
const ChatFolderInviteLinksTypeID = 0x6c135313
// Ensuring interfaces in compile-time for ChatFolderInviteLinks.
var (
_ bin.Encoder = &ChatFolderInviteLinks{}
_ bin.Decoder = &ChatFolderInviteLinks{}
_ bin.BareEncoder = &ChatFolderInviteLinks{}
_ bin.BareDecoder = &ChatFolderInviteLinks{}
)
func (c *ChatFolderInviteLinks) Zero() bool {
if c == nil {
return true
}
if !(c.InviteLinks == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatFolderInviteLinks) String() string {
if c == nil {
return "ChatFolderInviteLinks(nil)"
}
type Alias ChatFolderInviteLinks
return fmt.Sprintf("ChatFolderInviteLinks%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatFolderInviteLinks) TypeID() uint32 {
return ChatFolderInviteLinksTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatFolderInviteLinks) TypeName() string {
return "chatFolderInviteLinks"
}
// TypeInfo returns info about TL type.
func (c *ChatFolderInviteLinks) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatFolderInviteLinks",
ID: ChatFolderInviteLinksTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "InviteLinks",
SchemaName: "invite_links",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatFolderInviteLinks) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderInviteLinks#6c135313 as nil")
}
b.PutID(ChatFolderInviteLinksTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatFolderInviteLinks) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderInviteLinks#6c135313 as nil")
}
b.PutInt(len(c.InviteLinks))
for idx, v := range c.InviteLinks {
if err := v.EncodeBare(b); err != nil {
return fmt.Errorf("unable to encode bare chatFolderInviteLinks#6c135313: field invite_links element with index %d: %w", idx, err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (c *ChatFolderInviteLinks) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderInviteLinks#6c135313 to nil")
}
if err := b.ConsumeID(ChatFolderInviteLinksTypeID); err != nil {
return fmt.Errorf("unable to decode chatFolderInviteLinks#6c135313: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatFolderInviteLinks) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderInviteLinks#6c135313 to nil")
}
{
headerLen, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode chatFolderInviteLinks#6c135313: field invite_links: %w", err)
}
if headerLen > 0 {
c.InviteLinks = make([]ChatFolderInviteLink, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
var value ChatFolderInviteLink
if err := value.DecodeBare(b); err != nil {
return fmt.Errorf("unable to decode bare chatFolderInviteLinks#6c135313: field invite_links: %w", err)
}
c.InviteLinks = append(c.InviteLinks, value)
}
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatFolderInviteLinks) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode chatFolderInviteLinks#6c135313 as nil")
}
b.ObjStart()
b.PutID("chatFolderInviteLinks")
b.Comma()
b.FieldStart("invite_links")
b.ArrStart()
for idx, v := range c.InviteLinks {
if err := v.EncodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to encode chatFolderInviteLinks#6c135313: field invite_links element with index %d: %w", idx, err)
}
b.Comma()
}
b.StripComma()
b.ArrEnd()
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatFolderInviteLinks) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode chatFolderInviteLinks#6c135313 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("chatFolderInviteLinks"); err != nil {
return fmt.Errorf("unable to decode chatFolderInviteLinks#6c135313: %w", err)
}
case "invite_links":
if err := b.Arr(func(b tdjson.Decoder) error {
var value ChatFolderInviteLink
if err := value.DecodeTDLibJSON(b); err != nil {
return fmt.Errorf("unable to decode chatFolderInviteLinks#6c135313: field invite_links: %w", err)
}
c.InviteLinks = append(c.InviteLinks, value)
return nil
}); err != nil {
return fmt.Errorf("unable to decode chatFolderInviteLinks#6c135313: field invite_links: %w", err)
}
default:
return b.Skip()
}
return nil
})
}
// GetInviteLinks returns value of InviteLinks field.
func (c *ChatFolderInviteLinks) GetInviteLinks() (value []ChatFolderInviteLink) {
if c == nil {
return
}
return c.InviteLinks
}