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 StatsPublicForwards struct {
Flags bin .Fields
Count int
Forwards []PublicForwardClass
NextOffset string
Chats []ChatClass
Users []UserClass
}
const StatsPublicForwardsTypeID = 0x93037e20
var (
_ bin .Encoder = &StatsPublicForwards {}
_ bin .Decoder = &StatsPublicForwards {}
_ bin .BareEncoder = &StatsPublicForwards {}
_ bin .BareDecoder = &StatsPublicForwards {}
)
func (p *StatsPublicForwards ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Count == 0 ) {
return false
}
if !(p .Forwards == nil ) {
return false
}
if !(p .NextOffset == "" ) {
return false
}
if !(p .Chats == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *StatsPublicForwards ) String () string {
if p == nil {
return "StatsPublicForwards(nil)"
}
type Alias StatsPublicForwards
return fmt .Sprintf ("StatsPublicForwards%+v" , Alias (*p ))
}
func (p *StatsPublicForwards ) FillFrom (from interface {
GetCount () (value int )
GetForwards () (value []PublicForwardClass )
GetNextOffset () (value string , ok bool )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
p .Count = from .GetCount ()
p .Forwards = from .GetForwards ()
if val , ok := from .GetNextOffset (); ok {
p .NextOffset = val
}
p .Chats = from .GetChats ()
p .Users = from .GetUsers ()
}
func (*StatsPublicForwards ) TypeID () uint32 {
return StatsPublicForwardsTypeID
}
func (*StatsPublicForwards ) TypeName () string {
return "stats.publicForwards"
}
func (p *StatsPublicForwards ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stats.publicForwards" ,
ID : StatsPublicForwardsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Forwards" ,
SchemaName : "forwards" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *StatsPublicForwards ) SetFlags () {
if !(p .NextOffset == "" ) {
p .Flags .Set (0 )
}
}
func (p *StatsPublicForwards ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode stats.publicForwards#93037e20 as nil" )
}
b .PutID (StatsPublicForwardsTypeID )
return p .EncodeBare (b )
}
func (p *StatsPublicForwards ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode stats.publicForwards#93037e20 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field flags: %w" , err )
}
b .PutInt (p .Count )
b .PutVectorHeader (len (p .Forwards ))
for idx , v := range p .Forwards {
if v == nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field forwards element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field forwards element with index %d: %w" , idx , err )
}
}
if p .Flags .Has (0 ) {
b .PutString (p .NextOffset )
}
b .PutVectorHeader (len (p .Chats ))
for idx , v := range p .Chats {
if v == nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field chats 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 stats.publicForwards#93037e20: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stats.publicForwards#93037e20: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *StatsPublicForwards ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode stats.publicForwards#93037e20 to nil" )
}
if err := b .ConsumeID (StatsPublicForwardsTypeID ); err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: %w" , err )
}
return p .DecodeBare (b )
}
func (p *StatsPublicForwards ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode stats.publicForwards#93037e20 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field count: %w" , err )
}
p .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field forwards: %w" , err )
}
if headerLen > 0 {
p .Forwards = make ([]PublicForwardClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodePublicForward (b )
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field forwards: %w" , err )
}
p .Forwards = append (p .Forwards , value )
}
}
if p .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field next_offset: %w" , err )
}
p .NextOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: field chats: %w" , err )
}
if headerLen > 0 {
p .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 stats.publicForwards#93037e20: field chats: %w" , err )
}
p .Chats = append (p .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stats.publicForwards#93037e20: 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 stats.publicForwards#93037e20: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *StatsPublicForwards ) GetCount () (value int ) {
if p == nil {
return
}
return p .Count
}
func (p *StatsPublicForwards ) GetForwards () (value []PublicForwardClass ) {
if p == nil {
return
}
return p .Forwards
}
func (p *StatsPublicForwards ) SetNextOffset (value string ) {
p .Flags .Set (0 )
p .NextOffset = value
}
func (p *StatsPublicForwards ) GetNextOffset () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .NextOffset , true
}
func (p *StatsPublicForwards ) GetChats () (value []ChatClass ) {
if p == nil {
return
}
return p .Chats
}
func (p *StatsPublicForwards ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *StatsPublicForwards ) MapForwards () (value PublicForwardClassArray ) {
return PublicForwardClassArray (p .Forwards )
}
func (p *StatsPublicForwards ) MapChats () (value ChatClassArray ) {
return ChatClassArray (p .Chats )
}
func (p *StatsPublicForwards ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .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 .