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 PhoneJoinAsPeers struct {
Peers []PeerClass
Chats []ChatClass
Users []UserClass
}
const PhoneJoinAsPeersTypeID = 0xafe5623f
var (
_ bin .Encoder = &PhoneJoinAsPeers {}
_ bin .Decoder = &PhoneJoinAsPeers {}
_ bin .BareEncoder = &PhoneJoinAsPeers {}
_ bin .BareDecoder = &PhoneJoinAsPeers {}
)
func (j *PhoneJoinAsPeers ) Zero () bool {
if j == nil {
return true
}
if !(j .Peers == nil ) {
return false
}
if !(j .Chats == nil ) {
return false
}
if !(j .Users == nil ) {
return false
}
return true
}
func (j *PhoneJoinAsPeers ) String () string {
if j == nil {
return "PhoneJoinAsPeers(nil)"
}
type Alias PhoneJoinAsPeers
return fmt .Sprintf ("PhoneJoinAsPeers%+v" , Alias (*j ))
}
func (j *PhoneJoinAsPeers ) FillFrom (from interface {
GetPeers () (value []PeerClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
j .Peers = from .GetPeers ()
j .Chats = from .GetChats ()
j .Users = from .GetUsers ()
}
func (*PhoneJoinAsPeers ) TypeID () uint32 {
return PhoneJoinAsPeersTypeID
}
func (*PhoneJoinAsPeers ) TypeName () string {
return "phone.joinAsPeers"
}
func (j *PhoneJoinAsPeers ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phone.joinAsPeers" ,
ID : PhoneJoinAsPeersTypeID ,
}
if j == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peers" ,
SchemaName : "peers" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (j *PhoneJoinAsPeers ) Encode (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't encode phone.joinAsPeers#afe5623f as nil" )
}
b .PutID (PhoneJoinAsPeersTypeID )
return j .EncodeBare (b )
}
func (j *PhoneJoinAsPeers ) EncodeBare (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't encode phone.joinAsPeers#afe5623f as nil" )
}
b .PutVectorHeader (len (j .Peers ))
for idx , v := range j .Peers {
if v == nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field peers element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (j .Chats ))
for idx , v := range j .Chats {
if v == nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (j .Users ))
for idx , v := range j .Users {
if v == nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phone.joinAsPeers#afe5623f: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (j *PhoneJoinAsPeers ) Decode (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't decode phone.joinAsPeers#afe5623f to nil" )
}
if err := b .ConsumeID (PhoneJoinAsPeersTypeID ); err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: %w" , err )
}
return j .DecodeBare (b )
}
func (j *PhoneJoinAsPeers ) DecodeBare (b *bin .Buffer ) error {
if j == nil {
return fmt .Errorf ("can't decode phone.joinAsPeers#afe5623f to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field peers: %w" , err )
}
if headerLen > 0 {
j .Peers = make ([]PeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field peers: %w" , err )
}
j .Peers = append (j .Peers , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field chats: %w" , err )
}
if headerLen > 0 {
j .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field chats: %w" , err )
}
j .Chats = append (j .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field users: %w" , err )
}
if headerLen > 0 {
j .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode phone.joinAsPeers#afe5623f: field users: %w" , err )
}
j .Users = append (j .Users , value )
}
}
return nil
}
func (j *PhoneJoinAsPeers ) GetPeers () (value []PeerClass ) {
if j == nil {
return
}
return j .Peers
}
func (j *PhoneJoinAsPeers ) GetChats () (value []ChatClass ) {
if j == nil {
return
}
return j .Chats
}
func (j *PhoneJoinAsPeers ) GetUsers () (value []UserClass ) {
if j == nil {
return
}
return j .Users
}
func (j *PhoneJoinAsPeers ) MapPeers () (value PeerClassArray ) {
return PeerClassArray (j .Peers )
}
func (j *PhoneJoinAsPeers ) MapChats () (value ChatClassArray ) {
return ChatClassArray (j .Chats )
}
func (j *PhoneJoinAsPeers ) MapUsers () (value UserClassArray ) {
return UserClassArray (j .Users )
}
The pages are generated with Golds v0.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .