// 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{}
)

// PhoneGroupParticipants represents TL type `phone.groupParticipants#f47751b6`.
// Info about the participants of a group call or livestream
//
// See https://core.telegram.org/constructor/phone.groupParticipants for reference.
type PhoneGroupParticipants struct {
	// Number of participants
	Count int
	// List of participants
	Participants []GroupCallParticipant
	// If not empty, the specified list of participants is partial, and more participants can
	// be fetched specifying this parameter as offset in phone.getGroupParticipantsĀ¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/phone.getGroupParticipants
	NextOffset string
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
	// Version info
	Version int
}

// PhoneGroupParticipantsTypeID is TL type id of PhoneGroupParticipants.
const PhoneGroupParticipantsTypeID = 0xf47751b6

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

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

	return true
}

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

// FillFrom fills PhoneGroupParticipants from given interface.
func ( *PhoneGroupParticipants) ( interface {
	() ( int)
	() ( []GroupCallParticipant)
	() ( string)
	() ( []ChatClass)
	() ( []UserClass)
	() ( int)
}) {
	.Count = .()
	.Participants = .()
	.NextOffset = .()
	.Chats = .()
	.Users = .()
	.Version = .()
}

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

// TypeName returns name of type in TL schema.
func (*PhoneGroupParticipants) () string {
	return "phone.groupParticipants"
}

// TypeInfo returns info about TL type.
func ( *PhoneGroupParticipants) () tdp.Type {
	 := tdp.Type{
		Name: "phone.groupParticipants",
		ID:   PhoneGroupParticipantsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Participants",
			SchemaName: "participants",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "Version",
			SchemaName: "version",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneGroupParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phone.groupParticipants#f47751b6 as nil")
	}
	.PutID(PhoneGroupParticipantsTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *PhoneGroupParticipants) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phone.groupParticipants#f47751b6 to nil")
	}
	if  := .ConsumeID(PhoneGroupParticipantsTypeID);  != nil {
		return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: %w", )
	}
	return .DecodeBare()
}

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

		if  > 0 {
			.Participants = make([]GroupCallParticipant, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  GroupCallParticipant
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field participants: %w", )
			}
			.Participants = append(.Participants, )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field next_offset: %w", )
		}
		.NextOffset = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field chats: %w", )
		}

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

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode phone.groupParticipants#f47751b6: field version: %w", )
		}
		.Version = 
	}
	return nil
}

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

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

// GetNextOffset returns value of NextOffset field.
func ( *PhoneGroupParticipants) () ( string) {
	if  == nil {
		return
	}
	return .NextOffset
}

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

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

// GetVersion returns value of Version field.
func ( *PhoneGroupParticipants) () ( int) {
	if  == nil {
		return
	}
	return .Version
}

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

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