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

// ChatlistsChatlistUpdates represents TL type `chatlists.chatlistUpdates#93bd878d`.
// Updated information about a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/constructor/chatlists.chatlistUpdates for reference.
type ChatlistsChatlistUpdates struct {
	// New peers to join
	MissingPeers []PeerClass
	// Related chat information
	Chats []ChatClass
	// Related user information
	Users []UserClass
}

// ChatlistsChatlistUpdatesTypeID is TL type id of ChatlistsChatlistUpdates.
const ChatlistsChatlistUpdatesTypeID = 0x93bd878d

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

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

	return true
}

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

// FillFrom fills ChatlistsChatlistUpdates from given interface.
func ( *ChatlistsChatlistUpdates) ( interface {
	() ( []PeerClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.MissingPeers = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*ChatlistsChatlistUpdates) () string {
	return "chatlists.chatlistUpdates"
}

// TypeInfo returns info about TL type.
func ( *ChatlistsChatlistUpdates) () tdp.Type {
	 := tdp.Type{
		Name: "chatlists.chatlistUpdates",
		ID:   ChatlistsChatlistUpdatesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MissingPeers",
			SchemaName: "missing_peers",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatlistsChatlistUpdates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.chatlistUpdates#93bd878d as nil")
	}
	.PutID(ChatlistsChatlistUpdatesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatlistsChatlistUpdates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.chatlistUpdates#93bd878d as nil")
	}
	.PutVectorHeader(len(.MissingPeers))
	for ,  := range .MissingPeers {
		if  == nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field missing_peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field missing_peers element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatlists.chatlistUpdates#93bd878d: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatlistsChatlistUpdates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatlists.chatlistUpdates#93bd878d to nil")
	}
	if  := .ConsumeID(ChatlistsChatlistUpdatesTypeID);  != nil {
		return fmt.Errorf("unable to decode chatlists.chatlistUpdates#93bd878d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatlistsChatlistUpdates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatlists.chatlistUpdates#93bd878d to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.chatlistUpdates#93bd878d: field missing_peers: %w", )
		}

		if  > 0 {
			.MissingPeers = make([]PeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePeer()
			if  != nil {
				return fmt.Errorf("unable to decode chatlists.chatlistUpdates#93bd878d: field missing_peers: %w", )
			}
			.MissingPeers = append(.MissingPeers, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.chatlistUpdates#93bd878d: field chats: %w", )
		}

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

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

// GetMissingPeers returns value of MissingPeers field.
func ( *ChatlistsChatlistUpdates) () ( []PeerClass) {
	if  == nil {
		return
	}
	return .MissingPeers
}

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

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

// MapMissingPeers returns field MissingPeers wrapped in PeerClassArray helper.
func ( *ChatlistsChatlistUpdates) () ( PeerClassArray) {
	return PeerClassArray(.MissingPeers)
}

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

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