package tg
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"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type AccountBusinessChatLinks struct {
Links []BusinessChatLink
Chats []ChatClass
Users []UserClass
}
const AccountBusinessChatLinksTypeID = 0xec43a2d1
var (
_ bin .Encoder = &AccountBusinessChatLinks {}
_ bin .Decoder = &AccountBusinessChatLinks {}
_ bin .BareEncoder = &AccountBusinessChatLinks {}
_ bin .BareDecoder = &AccountBusinessChatLinks {}
)
func (b *AccountBusinessChatLinks ) Zero () bool {
if b == nil {
return true
}
if !(b .Links == nil ) {
return false
}
if !(b .Chats == nil ) {
return false
}
if !(b .Users == nil ) {
return false
}
return true
}
func (b *AccountBusinessChatLinks ) String () string {
if b == nil {
return "AccountBusinessChatLinks(nil)"
}
type Alias AccountBusinessChatLinks
return fmt .Sprintf ("AccountBusinessChatLinks%+v" , Alias (*b ))
}
func (b *AccountBusinessChatLinks ) FillFrom (from interface {
GetLinks () (value []BusinessChatLink )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
b .Links = from .GetLinks ()
b .Chats = from .GetChats ()
b .Users = from .GetUsers ()
}
func (*AccountBusinessChatLinks ) TypeID () uint32 {
return AccountBusinessChatLinksTypeID
}
func (*AccountBusinessChatLinks ) TypeName () string {
return "account.businessChatLinks"
}
func (b *AccountBusinessChatLinks ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.businessChatLinks" ,
ID : AccountBusinessChatLinksTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Links" ,
SchemaName : "links" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (b *AccountBusinessChatLinks ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode account.businessChatLinks#ec43a2d1 as nil" )
}
buf .PutID (AccountBusinessChatLinksTypeID )
return b .EncodeBare (buf )
}
func (b *AccountBusinessChatLinks ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode account.businessChatLinks#ec43a2d1 as nil" )
}
buf .PutVectorHeader (len (b .Links ))
for idx , v := range b .Links {
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode account.businessChatLinks#ec43a2d1: field links element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Chats ))
for idx , v := range b .Chats {
if v == nil {
return fmt .Errorf ("unable to encode account.businessChatLinks#ec43a2d1: field chats element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode account.businessChatLinks#ec43a2d1: field chats element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Users ))
for idx , v := range b .Users {
if v == nil {
return fmt .Errorf ("unable to encode account.businessChatLinks#ec43a2d1: field users element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode account.businessChatLinks#ec43a2d1: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (b *AccountBusinessChatLinks ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode account.businessChatLinks#ec43a2d1 to nil" )
}
if err := buf .ConsumeID (AccountBusinessChatLinksTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *AccountBusinessChatLinks ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode account.businessChatLinks#ec43a2d1 to nil" )
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field links: %w" , err )
}
if headerLen > 0 {
b .Links = make ([]BusinessChatLink , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value BusinessChatLink
if err := value .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field links: %w" , err )
}
b .Links = append (b .Links , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field chats: %w" , err )
}
if headerLen > 0 {
b .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (buf )
if err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field chats: %w" , err )
}
b .Chats = append (b .Chats , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field users: %w" , err )
}
if headerLen > 0 {
b .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode account.businessChatLinks#ec43a2d1: field users: %w" , err )
}
b .Users = append (b .Users , value )
}
}
return nil
}
func (b *AccountBusinessChatLinks ) GetLinks () (value []BusinessChatLink ) {
if b == nil {
return
}
return b .Links
}
func (b *AccountBusinessChatLinks ) GetChats () (value []ChatClass ) {
if b == nil {
return
}
return b .Chats
}
func (b *AccountBusinessChatLinks ) GetUsers () (value []UserClass ) {
if b == nil {
return
}
return b .Users
}
func (b *AccountBusinessChatLinks ) MapChats () (value ChatClassArray ) {
return ChatClassArray (b .Chats )
}
func (b *AccountBusinessChatLinks ) MapUsers () (value UserClassArray ) {
return UserClassArray (b .Users )
}
The pages are generated with Golds v0.8.4 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .