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 ContactsResolvedPeer struct {
Peer PeerClass
Chats []ChatClass
Users []UserClass
}
const ContactsResolvedPeerTypeID = 0x7f077ad9
var (
_ bin .Encoder = &ContactsResolvedPeer {}
_ bin .Decoder = &ContactsResolvedPeer {}
_ bin .BareEncoder = &ContactsResolvedPeer {}
_ bin .BareDecoder = &ContactsResolvedPeer {}
)
func (r *ContactsResolvedPeer ) Zero () bool {
if r == nil {
return true
}
if !(r .Peer == nil ) {
return false
}
if !(r .Chats == nil ) {
return false
}
if !(r .Users == nil ) {
return false
}
return true
}
func (r *ContactsResolvedPeer ) String () string {
if r == nil {
return "ContactsResolvedPeer(nil)"
}
type Alias ContactsResolvedPeer
return fmt .Sprintf ("ContactsResolvedPeer%+v" , Alias (*r ))
}
func (r *ContactsResolvedPeer ) FillFrom (from interface {
GetPeer () (value PeerClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
r .Peer = from .GetPeer ()
r .Chats = from .GetChats ()
r .Users = from .GetUsers ()
}
func (*ContactsResolvedPeer ) TypeID () uint32 {
return ContactsResolvedPeerTypeID
}
func (*ContactsResolvedPeer ) TypeName () string {
return "contacts.resolvedPeer"
}
func (r *ContactsResolvedPeer ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.resolvedPeer" ,
ID : ContactsResolvedPeerTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Peer" ,
SchemaName : "peer" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (r *ContactsResolvedPeer ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode contacts.resolvedPeer#7f077ad9 as nil" )
}
b .PutID (ContactsResolvedPeerTypeID )
return r .EncodeBare (b )
}
func (r *ContactsResolvedPeer ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode contacts.resolvedPeer#7f077ad9 as nil" )
}
if r .Peer == nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field peer is nil" )
}
if err := r .Peer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field peer: %w" , err )
}
b .PutVectorHeader (len (r .Chats ))
for idx , v := range r .Chats {
if v == nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (r .Users ))
for idx , v := range r .Users {
if v == nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.resolvedPeer#7f077ad9: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (r *ContactsResolvedPeer ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode contacts.resolvedPeer#7f077ad9 to nil" )
}
if err := b .ConsumeID (ContactsResolvedPeerTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.resolvedPeer#7f077ad9: %w" , err )
}
return r .DecodeBare (b )
}
func (r *ContactsResolvedPeer ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode contacts.resolvedPeer#7f077ad9 to nil" )
}
{
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode contacts.resolvedPeer#7f077ad9: field peer: %w" , err )
}
r .Peer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.resolvedPeer#7f077ad9: field chats: %w" , err )
}
if headerLen > 0 {
r .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 contacts.resolvedPeer#7f077ad9: field chats: %w" , err )
}
r .Chats = append (r .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.resolvedPeer#7f077ad9: field users: %w" , err )
}
if headerLen > 0 {
r .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 contacts.resolvedPeer#7f077ad9: field users: %w" , err )
}
r .Users = append (r .Users , value )
}
}
return nil
}
func (r *ContactsResolvedPeer ) GetPeer () (value PeerClass ) {
if r == nil {
return
}
return r .Peer
}
func (r *ContactsResolvedPeer ) GetChats () (value []ChatClass ) {
if r == nil {
return
}
return r .Chats
}
func (r *ContactsResolvedPeer ) GetUsers () (value []UserClass ) {
if r == nil {
return
}
return r .Users
}
func (r *ContactsResolvedPeer ) MapChats () (value ChatClassArray ) {
return ChatClassArray (r .Chats )
}
func (r *ContactsResolvedPeer ) MapUsers () (value UserClassArray ) {
return UserClassArray (r .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 .