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 ContactsContactBirthdays struct {
Contacts []ContactBirthday
Users []UserClass
}
const ContactsContactBirthdaysTypeID = 0x114ff30d
var (
_ bin .Encoder = &ContactsContactBirthdays {}
_ bin .Decoder = &ContactsContactBirthdays {}
_ bin .BareEncoder = &ContactsContactBirthdays {}
_ bin .BareDecoder = &ContactsContactBirthdays {}
)
func (c *ContactsContactBirthdays ) Zero () bool {
if c == nil {
return true
}
if !(c .Contacts == nil ) {
return false
}
if !(c .Users == nil ) {
return false
}
return true
}
func (c *ContactsContactBirthdays ) String () string {
if c == nil {
return "ContactsContactBirthdays(nil)"
}
type Alias ContactsContactBirthdays
return fmt .Sprintf ("ContactsContactBirthdays%+v" , Alias (*c ))
}
func (c *ContactsContactBirthdays ) FillFrom (from interface {
GetContacts () (value []ContactBirthday )
GetUsers () (value []UserClass )
}) {
c .Contacts = from .GetContacts ()
c .Users = from .GetUsers ()
}
func (*ContactsContactBirthdays ) TypeID () uint32 {
return ContactsContactBirthdaysTypeID
}
func (*ContactsContactBirthdays ) TypeName () string {
return "contacts.contactBirthdays"
}
func (c *ContactsContactBirthdays ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.contactBirthdays" ,
ID : ContactsContactBirthdaysTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Contacts" ,
SchemaName : "contacts" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (c *ContactsContactBirthdays ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contactBirthdays#114ff30d as nil" )
}
b .PutID (ContactsContactBirthdaysTypeID )
return c .EncodeBare (b )
}
func (c *ContactsContactBirthdays ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contacts.contactBirthdays#114ff30d 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.contactBirthdays#114ff30d: field contacts element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (c .Users ))
for idx , v := range c .Users {
if v == nil {
return fmt .Errorf ("unable to encode contacts.contactBirthdays#114ff30d: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.contactBirthdays#114ff30d: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (c *ContactsContactBirthdays ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contactBirthdays#114ff30d to nil" )
}
if err := b .ConsumeID (ContactsContactBirthdaysTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.contactBirthdays#114ff30d: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ContactsContactBirthdays ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contacts.contactBirthdays#114ff30d to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.contactBirthdays#114ff30d: field contacts: %w" , err )
}
if headerLen > 0 {
c .Contacts = make ([]ContactBirthday , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value ContactBirthday
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.contactBirthdays#114ff30d: field contacts: %w" , err )
}
c .Contacts = append (c .Contacts , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.contactBirthdays#114ff30d: 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.contactBirthdays#114ff30d: field users: %w" , err )
}
c .Users = append (c .Users , value )
}
}
return nil
}
func (c *ContactsContactBirthdays ) GetContacts () (value []ContactBirthday ) {
if c == nil {
return
}
return c .Contacts
}
func (c *ContactsContactBirthdays ) GetUsers () (value []UserClass ) {
if c == nil {
return
}
return c .Users
}
func (c *ContactsContactBirthdays ) MapUsers () (value UserClassArray ) {
return UserClassArray (c .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 .