// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// ChannelsChannelParticipants represents TL type `channels.channelParticipants#9ab0feaf`.
// Represents multiple channel participants
//
// See https://core.telegram.org/constructor/channels.channelParticipants for reference.
type ChannelsChannelParticipants struct {
	// Total number of participants that correspond to the given query
	Count int
	// Participants
	Participants []ChannelParticipantClass
	// Mentioned chats
	Chats []ChatClass
	// Users mentioned in participant info
	Users []UserClass
}

// ChannelsChannelParticipantsTypeID is TL type id of ChannelsChannelParticipants.
const ChannelsChannelParticipantsTypeID = 0x9ab0feaf

// construct implements constructor of ChannelsChannelParticipantsClass.
func ( ChannelsChannelParticipants) () ChannelsChannelParticipantsClass { return & }

// Ensuring interfaces in compile-time for ChannelsChannelParticipants.
var (
	_ bin.Encoder     = &ChannelsChannelParticipants{}
	_ bin.Decoder     = &ChannelsChannelParticipants{}
	_ bin.BareEncoder = &ChannelsChannelParticipants{}
	_ bin.BareDecoder = &ChannelsChannelParticipants{}

	_ ChannelsChannelParticipantsClass = &ChannelsChannelParticipants{}
)

func ( *ChannelsChannelParticipants) () bool {
	if  == nil {
		return true
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Participants == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *ChannelsChannelParticipants) () string {
	if  == nil {
		return "ChannelsChannelParticipants(nil)"
	}
	type  ChannelsChannelParticipants
	return fmt.Sprintf("ChannelsChannelParticipants%+v", (*))
}

// FillFrom fills ChannelsChannelParticipants from given interface.
func ( *ChannelsChannelParticipants) ( interface {
	() ( int)
	() ( []ChannelParticipantClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Count = .()
	.Participants = .()
	.Chats = .()
	.Users = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChannelsChannelParticipants) () uint32 {
	return ChannelsChannelParticipantsTypeID
}

// TypeName returns name of type in TL schema.
func (*ChannelsChannelParticipants) () string {
	return "channels.channelParticipants"
}

// TypeInfo returns info about TL type.
func ( *ChannelsChannelParticipants) () tdp.Type {
	 := tdp.Type{
		Name: "channels.channelParticipants",
		ID:   ChannelsChannelParticipantsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Participants",
			SchemaName: "participants",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsChannelParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.channelParticipants#9ab0feaf as nil")
	}
	.PutID(ChannelsChannelParticipantsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsChannelParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.channelParticipants#9ab0feaf as nil")
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Participants))
	for ,  := range .Participants {
		if  == nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field participants element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field participants element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode channels.channelParticipants#9ab0feaf: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsChannelParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.channelParticipants#9ab0feaf to nil")
	}
	if  := .ConsumeID(ChannelsChannelParticipantsTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsChannelParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.channelParticipants#9ab0feaf to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field participants: %w", )
		}

		if  > 0 {
			.Participants = make([]ChannelParticipantClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChannelParticipant()
			if  != nil {
				return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field participants: %w", )
			}
			.Participants = append(.Participants, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode channels.channelParticipants#9ab0feaf: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetCount returns value of Count field.
func ( *ChannelsChannelParticipants) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// GetParticipants returns value of Participants field.
func ( *ChannelsChannelParticipants) () ( []ChannelParticipantClass) {
	if  == nil {
		return
	}
	return .Participants
}

// GetChats returns value of Chats field.
func ( *ChannelsChannelParticipants) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *ChannelsChannelParticipants) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapParticipants returns field Participants wrapped in ChannelParticipantClassArray helper.
func ( *ChannelsChannelParticipants) () ( ChannelParticipantClassArray) {
	return ChannelParticipantClassArray(.Participants)
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *ChannelsChannelParticipants) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *ChannelsChannelParticipants) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// ChannelsChannelParticipantsNotModified represents TL type `channels.channelParticipantsNotModified#f0173fe9`.
// No new participant info could be found
//
// See https://core.telegram.org/constructor/channels.channelParticipantsNotModified for reference.
type ChannelsChannelParticipantsNotModified struct {
}

// ChannelsChannelParticipantsNotModifiedTypeID is TL type id of ChannelsChannelParticipantsNotModified.
const ChannelsChannelParticipantsNotModifiedTypeID = 0xf0173fe9

// construct implements constructor of ChannelsChannelParticipantsClass.
func ( ChannelsChannelParticipantsNotModified) () ChannelsChannelParticipantsClass {
	return &
}

// Ensuring interfaces in compile-time for ChannelsChannelParticipantsNotModified.
var (
	_ bin.Encoder     = &ChannelsChannelParticipantsNotModified{}
	_ bin.Decoder     = &ChannelsChannelParticipantsNotModified{}
	_ bin.BareEncoder = &ChannelsChannelParticipantsNotModified{}
	_ bin.BareDecoder = &ChannelsChannelParticipantsNotModified{}

	_ ChannelsChannelParticipantsClass = &ChannelsChannelParticipantsNotModified{}
)

func ( *ChannelsChannelParticipantsNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *ChannelsChannelParticipantsNotModified) () string {
	if  == nil {
		return "ChannelsChannelParticipantsNotModified(nil)"
	}
	type  ChannelsChannelParticipantsNotModified
	return fmt.Sprintf("ChannelsChannelParticipantsNotModified%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ChannelsChannelParticipantsNotModified) () uint32 {
	return ChannelsChannelParticipantsNotModifiedTypeID
}

// TypeName returns name of type in TL schema.
func (*ChannelsChannelParticipantsNotModified) () string {
	return "channels.channelParticipantsNotModified"
}

// TypeInfo returns info about TL type.
func ( *ChannelsChannelParticipantsNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "channels.channelParticipantsNotModified",
		ID:   ChannelsChannelParticipantsNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsChannelParticipantsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.channelParticipantsNotModified#f0173fe9 as nil")
	}
	.PutID(ChannelsChannelParticipantsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsChannelParticipantsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.channelParticipantsNotModified#f0173fe9 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsChannelParticipantsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.channelParticipantsNotModified#f0173fe9 to nil")
	}
	if  := .ConsumeID(ChannelsChannelParticipantsNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.channelParticipantsNotModified#f0173fe9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsChannelParticipantsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.channelParticipantsNotModified#f0173fe9 to nil")
	}
	return nil
}

// ChannelsChannelParticipantsClassName is schema name of ChannelsChannelParticipantsClass.
const ChannelsChannelParticipantsClassName = "channels.ChannelParticipants"

// ChannelsChannelParticipantsClass represents channels.ChannelParticipants generic type.
//
// See https://core.telegram.org/type/channels.ChannelParticipants for reference.
//
// Example:
//
//	g, err := tg.DecodeChannelsChannelParticipants(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChannelsChannelParticipants: // channels.channelParticipants#9ab0feaf
//	case *tg.ChannelsChannelParticipantsNotModified: // channels.channelParticipantsNotModified#f0173fe9
//	default: panic(v)
//	}
type ChannelsChannelParticipantsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChannelsChannelParticipantsClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsModified tries to map ChannelsChannelParticipantsClass to ChannelsChannelParticipants.
	AsModified() (*ChannelsChannelParticipants, bool)
}

// AsModified tries to map ChannelsChannelParticipants to ChannelsChannelParticipants.
func ( *ChannelsChannelParticipants) () (*ChannelsChannelParticipants, bool) {
	return , true
}

// AsModified tries to map ChannelsChannelParticipantsNotModified to ChannelsChannelParticipants.
func ( *ChannelsChannelParticipantsNotModified) () (*ChannelsChannelParticipants, bool) {
	return nil, false
}

// DecodeChannelsChannelParticipants implements binary de-serialization for ChannelsChannelParticipantsClass.
func ( *bin.Buffer) (ChannelsChannelParticipantsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChannelsChannelParticipantsTypeID:
		// Decoding channels.channelParticipants#9ab0feaf.
		 := ChannelsChannelParticipants{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelsChannelParticipantsClass: %w", )
		}
		return &, nil
	case ChannelsChannelParticipantsNotModifiedTypeID:
		// Decoding channels.channelParticipantsNotModified#f0173fe9.
		 := ChannelsChannelParticipantsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChannelsChannelParticipantsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChannelsChannelParticipantsClass: %w", bin.NewUnexpectedID())
	}
}

// ChannelsChannelParticipants boxes the ChannelsChannelParticipantsClass providing a helper.
type ChannelsChannelParticipantsBox struct {
	ChannelParticipants ChannelsChannelParticipantsClass
}

// Decode implements bin.Decoder for ChannelsChannelParticipantsBox.
func ( *ChannelsChannelParticipantsBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode ChannelsChannelParticipantsBox to nil")
	}
	,  := DecodeChannelsChannelParticipants()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.ChannelParticipants = 
	return nil
}

// Encode implements bin.Encode for ChannelsChannelParticipantsBox.
func ( *ChannelsChannelParticipantsBox) ( *bin.Buffer) error {
	if  == nil || .ChannelParticipants == nil {
		return fmt.Errorf("unable to encode ChannelsChannelParticipantsClass as nil")
	}
	return .ChannelParticipants.Encode()
}