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

228 lines
4.9 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{}
)
// ChatBoostLink represents TL type `chatBoostLink#b5417c71`.
type ChatBoostLink struct {
// The link
Link string
// True, if the link will work for non-members of the chat
IsPublic bool
}
// ChatBoostLinkTypeID is TL type id of ChatBoostLink.
const ChatBoostLinkTypeID = 0xb5417c71
// Ensuring interfaces in compile-time for ChatBoostLink.
var (
_ bin.Encoder = &ChatBoostLink{}
_ bin.Decoder = &ChatBoostLink{}
_ bin.BareEncoder = &ChatBoostLink{}
_ bin.BareDecoder = &ChatBoostLink{}
)
func (c *ChatBoostLink) Zero() bool {
if c == nil {
return true
}
if !(c.Link == "") {
return false
}
if !(c.IsPublic == false) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *ChatBoostLink) String() string {
if c == nil {
return "ChatBoostLink(nil)"
}
type Alias ChatBoostLink
return fmt.Sprintf("ChatBoostLink%+v", Alias(*c))
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChatBoostLink) TypeID() uint32 {
return ChatBoostLinkTypeID
}
// TypeName returns name of type in TL schema.
func (*ChatBoostLink) TypeName() string {
return "chatBoostLink"
}
// TypeInfo returns info about TL type.
func (c *ChatBoostLink) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "chatBoostLink",
ID: ChatBoostLinkTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Link",
SchemaName: "link",
},
{
Name: "IsPublic",
SchemaName: "is_public",
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *ChatBoostLink) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostLink#b5417c71 as nil")
}
b.PutID(ChatBoostLinkTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *ChatBoostLink) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostLink#b5417c71 as nil")
}
b.PutString(c.Link)
b.PutBool(c.IsPublic)
return nil
}
// Decode implements bin.Decoder.
func (c *ChatBoostLink) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostLink#b5417c71 to nil")
}
if err := b.ConsumeID(ChatBoostLinkTypeID); err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *ChatBoostLink) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostLink#b5417c71 to nil")
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: field link: %w", err)
}
c.Link = value
}
{
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: field is_public: %w", err)
}
c.IsPublic = value
}
return nil
}
// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *ChatBoostLink) EncodeTDLibJSON(b tdjson.Encoder) error {
if c == nil {
return fmt.Errorf("can't encode chatBoostLink#b5417c71 as nil")
}
b.ObjStart()
b.PutID("chatBoostLink")
b.Comma()
b.FieldStart("link")
b.PutString(c.Link)
b.Comma()
b.FieldStart("is_public")
b.PutBool(c.IsPublic)
b.Comma()
b.StripComma()
b.ObjEnd()
return nil
}
// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *ChatBoostLink) DecodeTDLibJSON(b tdjson.Decoder) error {
if c == nil {
return fmt.Errorf("can't decode chatBoostLink#b5417c71 to nil")
}
return b.Obj(func(b tdjson.Decoder, key []byte) error {
switch string(key) {
case tdjson.TypeField:
if err := b.ConsumeID("chatBoostLink"); err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: %w", err)
}
case "link":
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: field link: %w", err)
}
c.Link = value
case "is_public":
value, err := b.Bool()
if err != nil {
return fmt.Errorf("unable to decode chatBoostLink#b5417c71: field is_public: %w", err)
}
c.IsPublic = value
default:
return b.Skip()
}
return nil
})
}
// GetLink returns value of Link field.
func (c *ChatBoostLink) GetLink() (value string) {
if c == nil {
return
}
return c.Link
}
// GetIsPublic returns value of IsPublic field.
func (c *ChatBoostLink) GetIsPublic() (value bool) {
if c == nil {
return
}
return c.IsPublic
}