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

// MessagesMessageReactionsList represents TL type `messages.messageReactionsList#31bd492d`.
// List of peers that reacted to a specific message
//
// See https://core.telegram.org/constructor/messages.messageReactionsList for reference.
type MessagesMessageReactionsList struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Total number of reactions matching query
	Count int
	// List of peers that reacted to a specific message
	Reactions []MessagePeerReaction
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
	// If set, indicates the next offset to use to load more results by invoking messages
	// getMessageReactionsList¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.getMessageReactionsList
	//
	// Use SetNextOffset and GetNextOffset helpers.
	NextOffset string
}

// MessagesMessageReactionsListTypeID is TL type id of MessagesMessageReactionsList.
const MessagesMessageReactionsListTypeID = 0x31bd492d

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

func ( *MessagesMessageReactionsList) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Reactions == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.NextOffset == "") {
		return false
	}

	return true
}

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

// FillFrom fills MessagesMessageReactionsList from given interface.
func ( *MessagesMessageReactionsList) ( interface {
	() ( int)
	() ( []MessagePeerReaction)
	() ( []ChatClass)
	() ( []UserClass)
	() ( string,  bool)
}) {
	.Count = .()
	.Reactions = .()
	.Chats = .()
	.Users = .()
	if ,  := .();  {
		.NextOffset = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesMessageReactionsList) () tdp.Type {
	 := tdp.Type{
		Name: "messages.messageReactionsList",
		ID:   MessagesMessageReactionsListTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesMessageReactionsList) () {
	if !(.NextOffset == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesMessageReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messageReactionsList#31bd492d as nil")
	}
	.PutID(MessagesMessageReactionsListTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesMessageReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messageReactionsList#31bd492d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field flags: %w", )
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Reactions))
	for ,  := range .Reactions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field reactions element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messageReactionsList#31bd492d: field users element with index %d: %w", , )
		}
	}
	if .Flags.Has(0) {
		.PutString(.NextOffset)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesMessageReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messageReactionsList#31bd492d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field reactions: %w", )
		}

		if  > 0 {
			.Reactions = make([]MessagePeerReaction, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  MessagePeerReaction
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field reactions: %w", )
			}
			.Reactions = append(.Reactions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field chats: %w", )
		}

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

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messageReactionsList#31bd492d: field next_offset: %w", )
		}
		.NextOffset = 
	}
	return nil
}

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

// GetReactions returns value of Reactions field.
func ( *MessagesMessageReactionsList) () ( []MessagePeerReaction) {
	if  == nil {
		return
	}
	return .Reactions
}

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

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

// SetNextOffset sets value of NextOffset conditional field.
func ( *MessagesMessageReactionsList) ( string) {
	.Flags.Set(0)
	.NextOffset = 
}

// GetNextOffset returns value of NextOffset conditional field and
// boolean which is true if field was set.
func ( *MessagesMessageReactionsList) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NextOffset, true
}

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

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