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

// MessagesPeerDialogs represents TL type `messages.peerDialogs#3371c354`.
// Dialog info of multiple peers
//
// See https://core.telegram.org/constructor/messages.peerDialogs for reference.
type MessagesPeerDialogs struct {
	// Dialog info
	Dialogs []DialogClass
	// Messages mentioned in dialog info
	Messages []MessageClass
	// Chats
	Chats []ChatClass
	// Users
	Users []UserClass
	// Current update state of dialogĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	State UpdatesState
}

// MessagesPeerDialogsTypeID is TL type id of MessagesPeerDialogs.
const MessagesPeerDialogsTypeID = 0x3371c354

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

func ( *MessagesPeerDialogs) () bool {
	if  == nil {
		return true
	}
	if !(.Dialogs == nil) {
		return false
	}
	if !(.Messages == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.State.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesPeerDialogs from given interface.
func ( *MessagesPeerDialogs) ( interface {
	() ( []DialogClass)
	() ( []MessageClass)
	() ( []ChatClass)
	() ( []UserClass)
	() ( UpdatesState)
}) {
	.Dialogs = .()
	.Messages = .()
	.Chats = .()
	.Users = .()
	.State = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesPeerDialogs) () tdp.Type {
	 := tdp.Type{
		Name: "messages.peerDialogs",
		ID:   MessagesPeerDialogsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Dialogs",
			SchemaName: "dialogs",
		},
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "State",
			SchemaName: "state",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesPeerDialogs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.peerDialogs#3371c354 as nil")
	}
	.PutID(MessagesPeerDialogsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesPeerDialogs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.peerDialogs#3371c354 as nil")
	}
	.PutVectorHeader(len(.Dialogs))
	for ,  := range .Dialogs {
		if  == nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field dialogs element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field dialogs element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Messages))
	for ,  := range .Messages {
		if  == nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field users element with index %d: %w", , )
		}
	}
	if  := .State.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.peerDialogs#3371c354: field state: %w", )
	}
	return nil
}

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

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

		if  > 0 {
			.Dialogs = make([]DialogClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeDialog()
			if  != nil {
				return fmt.Errorf("unable to decode messages.peerDialogs#3371c354: field dialogs: %w", )
			}
			.Dialogs = append(.Dialogs, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.peerDialogs#3371c354: field messages: %w", )
		}

		if  > 0 {
			.Messages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode messages.peerDialogs#3371c354: field messages: %w", )
			}
			.Messages = append(.Messages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.peerDialogs#3371c354: field chats: %w", )
		}

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

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

// GetDialogs returns value of Dialogs field.
func ( *MessagesPeerDialogs) () ( []DialogClass) {
	if  == nil {
		return
	}
	return .Dialogs
}

// GetMessages returns value of Messages field.
func ( *MessagesPeerDialogs) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .Messages
}

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

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

// GetState returns value of State field.
func ( *MessagesPeerDialogs) () ( UpdatesState) {
	if  == nil {
		return
	}
	return .State
}

// MapDialogs returns field Dialogs wrapped in DialogClassArray helper.
func ( *MessagesPeerDialogs) () ( DialogClassArray) {
	return DialogClassArray(.Dialogs)
}

// MapMessages returns field Messages wrapped in MessageClassArray helper.
func ( *MessagesPeerDialogs) () ( MessageClassArray) {
	return MessageClassArray(.Messages)
}

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

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