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