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 ContactsContactsNotModified struct {
}
const ContactsContactsNotModifiedTypeID = 0xb74ba9d2
func (c ContactsContactsNotModified ) construct () ContactsContactsClass { return &c }
var (
_ bin .Encoder = &ContactsContactsNotModified {}
_ bin .Decoder = &ContactsContactsNotModified {}
_ bin .BareEncoder = &ContactsContactsNotModified {}
_ bin .BareDecoder = &ContactsContactsNotModified {}
_ ContactsContactsClass = &ContactsContactsNotModified {}
)
func (c *ContactsContactsNotModified ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *ContactsContactsNotModified ) String () string {
if c == nil {
return "ContactsContactsNotModified(nil)"
}
type Alias ContactsContactsNotModified
return fmt .Sprintf ("ContactsContactsNotModified%+v" , Alias (*c ))
}
func (*ContactsContactsNotModified ) TypeID () uint32 {
return ContactsContactsNotModifiedTypeID
}
func (*ContactsContactsNotModified ) TypeName () string {
return "contacts.contactsNotModified"
}
func (c *ContactsContactsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.contactsNotModified" ,
ID : ContactsContactsNotModifiedTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *ContactsContactsNotModified ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contactsNotModified#b74ba9d2 as nil" )
}
b .PutID (ContactsContactsNotModifiedTypeID )
return c .EncodeBare (b )
}
func (c *ContactsContactsNotModified ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contactsNotModified#b74ba9d2 as nil" )
}
return nil
}
func (c *ContactsContactsNotModified ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contactsNotModified#b74ba9d2 to nil" )
}
if err := b .ConsumeID (ContactsContactsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.contactsNotModified#b74ba9d2: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ContactsContactsNotModified ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contactsNotModified#b74ba9d2 to nil" )
}
return nil
}
type ContactsContacts struct {
Contacts []Contact
SavedCount int
Users []UserClass
}
const ContactsContactsTypeID = 0xeae87e42
func (c ContactsContacts ) construct () ContactsContactsClass { return &c }
var (
_ bin .Encoder = &ContactsContacts {}
_ bin .Decoder = &ContactsContacts {}
_ bin .BareEncoder = &ContactsContacts {}
_ bin .BareDecoder = &ContactsContacts {}
_ ContactsContactsClass = &ContactsContacts {}
)
func (c *ContactsContacts ) Zero () bool {
if c == nil {
return true
}
if !(c .Contacts == nil ) {
return false
}
if !(c .SavedCount == 0 ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *ContactsContacts ) String () string {
if c == nil {
return "ContactsContacts(nil)"
}
type Alias ContactsContacts
return fmt .Sprintf ("ContactsContacts%+v" , Alias (*c ))
}
func (c *ContactsContacts ) FillFrom (from interface {
GetContacts () (value []Contact )
GetSavedCount () (value int )
GetUsers () (value []UserClass )
}) {
c .Contacts = from .GetContacts ()
c .SavedCount = from .GetSavedCount ()
c .Users = from .GetUsers ()
}
func (*ContactsContacts ) TypeID () uint32 {
return ContactsContactsTypeID
}
func (*ContactsContacts ) TypeName () string {
return "contacts.contacts"
}
func (c *ContactsContacts ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.contacts" ,
ID : ContactsContactsTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Contacts" ,
SchemaName : "contacts" ,
},
{
Name : "SavedCount" ,
SchemaName : "saved_count" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *ContactsContacts ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contacts#eae87e42 as nil" )
}
b .PutID (ContactsContactsTypeID )
return c .EncodeBare (b )
}
func (c *ContactsContacts ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contacts#eae87e42 as nil" )
}
b .PutVectorHeader (len (c .Contacts ))
for idx , v := range c .Contacts {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.contacts#eae87e42: field contacts element with index %d: %w" , idx , err )
}
}
b .PutInt (c .SavedCount )
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode contacts.contacts#eae87e42: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.contacts#eae87e42: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *ContactsContacts ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contacts#eae87e42 to nil" )
}
if err := b .ConsumeID (ContactsContactsTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.contacts#eae87e42: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ContactsContacts ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contacts#eae87e42 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.contacts#eae87e42: field contacts: %w" , err )
}
if headerLen > 0 {
c .Contacts = make ([]Contact , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value Contact
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.contacts#eae87e42: field contacts: %w" , err )
}
c .Contacts = append (c .Contacts , value )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.contacts#eae87e42: field saved_count: %w" , err )
}
c .SavedCount = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.contacts#eae87e42: field users: %w" , err )
}
if headerLen > 0 {
c .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.contacts#eae87e42: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *ContactsContacts ) GetContacts () (value []Contact ) {
if c == nil {
return
}
return c .Contacts
}
func (c *ContactsContacts ) GetSavedCount () (value int ) {
if c == nil {
return
}
return c .SavedCount
}
func (c *ContactsContacts ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *ContactsContacts ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .Users )
}
const ContactsContactsClassName = "contacts.Contacts"
type ContactsContactsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ContactsContactsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*ContactsContacts , bool )
}
func (c *ContactsContactsNotModified ) AsModified () (*ContactsContacts , bool ) {
return nil , false
}
func (c *ContactsContacts ) AsModified () (*ContactsContacts , bool ) {
return c , true
}
func DecodeContactsContacts (buf *bin .Buffer ) (ContactsContactsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ContactsContactsNotModifiedTypeID :
v := ContactsContactsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ContactsContactsClass: %w" , err )
}
return &v , nil
case ContactsContactsTypeID :
v := ContactsContacts {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ContactsContactsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ContactsContactsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ContactsContactsBox struct {
Contacts ContactsContactsClass
}
func (b *ContactsContactsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ContactsContactsBox to nil" )
}
v , err := DecodeContactsContacts (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Contacts = v
return nil
}
func (b *ContactsContactsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Contacts == nil {
return fmt .Errorf ("unable to encode ContactsContactsClass as nil" )
}
return b .Contacts .Encode (buf )
}
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 .