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