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

// CommunitiesParticipantJoinedChats represents TL type `communities.participantJoinedChats#8d78512a`.
//
// See https://core.telegram.org/constructor/communities.participantJoinedChats for reference.
type CommunitiesParticipantJoinedChats struct {
	// CreatorChatIDs field of CommunitiesParticipantJoinedChats.
	CreatorChatIDs []int64
	// JoinedChatIDs field of CommunitiesParticipantJoinedChats.
	JoinedChatIDs []int64
	// Chats field of CommunitiesParticipantJoinedChats.
	Chats []ChatClass
	// Users field of CommunitiesParticipantJoinedChats.
	Users []UserClass
}

// CommunitiesParticipantJoinedChatsTypeID is TL type id of CommunitiesParticipantJoinedChats.
const CommunitiesParticipantJoinedChatsTypeID = 0x8d78512a

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

func ( *CommunitiesParticipantJoinedChats) () bool {
	if  == nil {
		return true
	}
	if !(.CreatorChatIDs == nil) {
		return false
	}
	if !(.JoinedChatIDs == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills CommunitiesParticipantJoinedChats from given interface.
func ( *CommunitiesParticipantJoinedChats) ( interface {
	() ( []int64)
	() ( []int64)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.CreatorChatIDs = .()
	.JoinedChatIDs = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*CommunitiesParticipantJoinedChats) () string {
	return "communities.participantJoinedChats"
}

// TypeInfo returns info about TL type.
func ( *CommunitiesParticipantJoinedChats) () tdp.Type {
	 := tdp.Type{
		Name: "communities.participantJoinedChats",
		ID:   CommunitiesParticipantJoinedChatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CreatorChatIDs",
			SchemaName: "creator_chat_ids",
		},
		{
			Name:       "JoinedChatIDs",
			SchemaName: "joined_chat_ids",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *CommunitiesParticipantJoinedChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.participantJoinedChats#8d78512a as nil")
	}
	.PutID(CommunitiesParticipantJoinedChatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *CommunitiesParticipantJoinedChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode communities.participantJoinedChats#8d78512a as nil")
	}
	.PutVectorHeader(len(.CreatorChatIDs))
	for ,  := range .CreatorChatIDs {
		.PutLong()
	}
	.PutVectorHeader(len(.JoinedChatIDs))
	for ,  := range .JoinedChatIDs {
		.PutLong()
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode communities.participantJoinedChats#8d78512a: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode communities.participantJoinedChats#8d78512a: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode communities.participantJoinedChats#8d78512a: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode communities.participantJoinedChats#8d78512a: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *CommunitiesParticipantJoinedChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.participantJoinedChats#8d78512a to nil")
	}
	if  := .ConsumeID(CommunitiesParticipantJoinedChatsTypeID);  != nil {
		return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *CommunitiesParticipantJoinedChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode communities.participantJoinedChats#8d78512a to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: field creator_chat_ids: %w", )
		}

		if  > 0 {
			.CreatorChatIDs = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: field creator_chat_ids: %w", )
			}
			.CreatorChatIDs = append(.CreatorChatIDs, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: field joined_chat_ids: %w", )
		}

		if  > 0 {
			.JoinedChatIDs = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: field joined_chat_ids: %w", )
			}
			.JoinedChatIDs = append(.JoinedChatIDs, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode communities.participantJoinedChats#8d78512a: field chats: %w", )
		}

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

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

// GetCreatorChatIDs returns value of CreatorChatIDs field.
func ( *CommunitiesParticipantJoinedChats) () ( []int64) {
	if  == nil {
		return
	}
	return .CreatorChatIDs
}

// GetJoinedChatIDs returns value of JoinedChatIDs field.
func ( *CommunitiesParticipantJoinedChats) () ( []int64) {
	if  == nil {
		return
	}
	return .JoinedChatIDs
}

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

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

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

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