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

// MessagesInactiveChats represents TL type `messages.inactiveChats#a927fec5`.
// Inactive chat list
//
// See https://core.telegram.org/constructor/messages.inactiveChats for reference.
type MessagesInactiveChats struct {
	// When was the chat last active
	Dates []int
	// Chat list
	Chats []ChatClass
	// Users mentioned in the chat list
	Users []UserClass
}

// MessagesInactiveChatsTypeID is TL type id of MessagesInactiveChats.
const MessagesInactiveChatsTypeID = 0xa927fec5

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

func ( *MessagesInactiveChats) () bool {
	if  == nil {
		return true
	}
	if !(.Dates == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesInactiveChats from given interface.
func ( *MessagesInactiveChats) ( interface {
	() ( []int)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Dates = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesInactiveChats) () string {
	return "messages.inactiveChats"
}

// TypeInfo returns info about TL type.
func ( *MessagesInactiveChats) () tdp.Type {
	 := tdp.Type{
		Name: "messages.inactiveChats",
		ID:   MessagesInactiveChatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Dates",
			SchemaName: "dates",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesInactiveChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.inactiveChats#a927fec5 as nil")
	}
	.PutID(MessagesInactiveChatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesInactiveChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.inactiveChats#a927fec5 as nil")
	}
	.PutVectorHeader(len(.Dates))
	for ,  := range .Dates {
		.PutInt()
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.inactiveChats#a927fec5: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.inactiveChats#a927fec5: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.inactiveChats#a927fec5: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.inactiveChats#a927fec5: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesInactiveChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.inactiveChats#a927fec5 to nil")
	}
	if  := .ConsumeID(MessagesInactiveChatsTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.inactiveChats#a927fec5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesInactiveChats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.inactiveChats#a927fec5 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.inactiveChats#a927fec5: field dates: %w", )
		}

		if  > 0 {
			.Dates = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode messages.inactiveChats#a927fec5: field dates: %w", )
			}
			.Dates = append(.Dates, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.inactiveChats#a927fec5: field chats: %w", )
		}

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

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

// GetDates returns value of Dates field.
func ( *MessagesInactiveChats) () ( []int) {
	if  == nil {
		return
	}
	return .Dates
}

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

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

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

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