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 PhotosPhotos struct {
Photos []PhotoClass
Users []UserClass
}
const PhotosPhotosTypeID = 0x8dca6aa5
func (p PhotosPhotos ) construct () PhotosPhotosClass { return &p }
var (
_ bin .Encoder = &PhotosPhotos {}
_ bin .Decoder = &PhotosPhotos {}
_ bin .BareEncoder = &PhotosPhotos {}
_ bin .BareDecoder = &PhotosPhotos {}
_ PhotosPhotosClass = &PhotosPhotos {}
)
func (p *PhotosPhotos ) Zero () bool {
if p == nil {
return true
}
if !(p .Photos == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *PhotosPhotos ) String () string {
if p == nil {
return "PhotosPhotos(nil)"
}
type Alias PhotosPhotos
return fmt .Sprintf ("PhotosPhotos%+v" , Alias (*p ))
}
func (p *PhotosPhotos ) FillFrom (from interface {
GetPhotos () (value []PhotoClass )
GetUsers () (value []UserClass )
}) {
p .Photos = from .GetPhotos ()
p .Users = from .GetUsers ()
}
func (*PhotosPhotos ) TypeID () uint32 {
return PhotosPhotosTypeID
}
func (*PhotosPhotos ) TypeName () string {
return "photos.photos"
}
func (p *PhotosPhotos ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.photos" ,
ID : PhotosPhotosTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Photos" ,
SchemaName : "photos" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *PhotosPhotos ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photos.photos#8dca6aa5 as nil" )
}
b .PutID (PhotosPhotosTypeID )
return p .EncodeBare (b )
}
func (p *PhotosPhotos ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photos.photos#8dca6aa5 as nil" )
}
b .PutVectorHeader (len (p .Photos ))
for idx , v := range p .Photos {
if v == nil {
return fmt .Errorf ("unable to encode photos.photos#8dca6aa5: field photos element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.photos#8dca6aa5: field photos element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode photos.photos#8dca6aa5: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.photos#8dca6aa5: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *PhotosPhotos ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photos.photos#8dca6aa5 to nil" )
}
if err := b .ConsumeID (PhotosPhotosTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.photos#8dca6aa5: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotosPhotos ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photos.photos#8dca6aa5 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photos.photos#8dca6aa5: field photos: %w" , err )
}
if headerLen > 0 {
p .Photos = make ([]PhotoClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.photos#8dca6aa5: field photos: %w" , err )
}
p .Photos = append (p .Photos , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photos.photos#8dca6aa5: field users: %w" , err )
}
if headerLen > 0 {
p .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 photos.photos#8dca6aa5: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *PhotosPhotos ) GetPhotos () (value []PhotoClass ) {
if p == nil {
return
}
return p .Photos
}
func (p *PhotosPhotos ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *PhotosPhotos ) MapPhotos () (value PhotoClassArray ) {
return PhotoClassArray (p .Photos )
}
func (p *PhotosPhotos ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
type PhotosPhotosSlice struct {
Count int
Photos []PhotoClass
Users []UserClass
}
const PhotosPhotosSliceTypeID = 0x15051f54
func (p PhotosPhotosSlice ) construct () PhotosPhotosClass { return &p }
var (
_ bin .Encoder = &PhotosPhotosSlice {}
_ bin .Decoder = &PhotosPhotosSlice {}
_ bin .BareEncoder = &PhotosPhotosSlice {}
_ bin .BareDecoder = &PhotosPhotosSlice {}
_ PhotosPhotosClass = &PhotosPhotosSlice {}
)
func (p *PhotosPhotosSlice ) Zero () bool {
if p == nil {
return true
}
if !(p .Count == 0 ) {
return false
}
if !(p .Photos == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *PhotosPhotosSlice ) String () string {
if p == nil {
return "PhotosPhotosSlice(nil)"
}
type Alias PhotosPhotosSlice
return fmt .Sprintf ("PhotosPhotosSlice%+v" , Alias (*p ))
}
func (p *PhotosPhotosSlice ) FillFrom (from interface {
GetCount () (value int )
GetPhotos () (value []PhotoClass )
GetUsers () (value []UserClass )
}) {
p .Count = from .GetCount ()
p .Photos = from .GetPhotos ()
p .Users = from .GetUsers ()
}
func (*PhotosPhotosSlice ) TypeID () uint32 {
return PhotosPhotosSliceTypeID
}
func (*PhotosPhotosSlice ) TypeName () string {
return "photos.photosSlice"
}
func (p *PhotosPhotosSlice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photos.photosSlice" ,
ID : PhotosPhotosSliceTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Photos" ,
SchemaName : "photos" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *PhotosPhotosSlice ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photos.photosSlice#15051f54 as nil" )
}
b .PutID (PhotosPhotosSliceTypeID )
return p .EncodeBare (b )
}
func (p *PhotosPhotosSlice ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photos.photosSlice#15051f54 as nil" )
}
b .PutInt (p .Count )
b .PutVectorHeader (len (p .Photos ))
for idx , v := range p .Photos {
if v == nil {
return fmt .Errorf ("unable to encode photos.photosSlice#15051f54: field photos element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.photosSlice#15051f54: field photos element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode photos.photosSlice#15051f54: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode photos.photosSlice#15051f54: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *PhotosPhotosSlice ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photos.photosSlice#15051f54 to nil" )
}
if err := b .ConsumeID (PhotosPhotosSliceTypeID ); err != nil {
return fmt .Errorf ("unable to decode photos.photosSlice#15051f54: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotosPhotosSlice ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photos.photosSlice#15051f54 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photos.photosSlice#15051f54: field count: %w" , err )
}
p .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photos.photosSlice#15051f54: field photos: %w" , err )
}
if headerLen > 0 {
p .Photos = make ([]PhotoClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePhoto (b )
if err != nil {
return fmt .Errorf ("unable to decode photos.photosSlice#15051f54: field photos: %w" , err )
}
p .Photos = append (p .Photos , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photos.photosSlice#15051f54: field users: %w" , err )
}
if headerLen > 0 {
p .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 photos.photosSlice#15051f54: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *PhotosPhotosSlice ) GetCount () (value int ) {
if p == nil {
return
}
return p .Count
}
func (p *PhotosPhotosSlice ) GetPhotos () (value []PhotoClass ) {
if p == nil {
return
}
return p .Photos
}
func (p *PhotosPhotosSlice ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *PhotosPhotosSlice ) MapPhotos () (value PhotoClassArray ) {
return PhotoClassArray (p .Photos )
}
func (p *PhotosPhotosSlice ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
const PhotosPhotosClassName = "photos.Photos"
type PhotosPhotosClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PhotosPhotosClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetPhotos () (value []PhotoClass )
MapPhotos () (value PhotoClassArray )
GetUsers () (value []UserClass )
MapUsers () (value UserClassArray )
}
func DecodePhotosPhotos (buf *bin .Buffer ) (PhotosPhotosClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PhotosPhotosTypeID :
v := PhotosPhotos {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotosPhotosClass: %w" , err )
}
return &v , nil
case PhotosPhotosSliceTypeID :
v := PhotosPhotosSlice {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotosPhotosClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PhotosPhotosClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PhotosPhotosBox struct {
Photos PhotosPhotosClass
}
func (b *PhotosPhotosBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PhotosPhotosBox to nil" )
}
v , err := DecodePhotosPhotos (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Photos = v
return nil
}
func (b *PhotosPhotosBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Photos == nil {
return fmt .Errorf ("unable to encode PhotosPhotosClass as nil" )
}
return b .Photos .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 .