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

// ReactionCount represents TL type `reactionCount#a3d1cb80`.
// Reactions
//
// See https://core.telegram.org/constructor/reactionCount for reference.
type ReactionCount struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, indicates that the current user also sent this reaction. The integer value
	// indicates when was the reaction added: the bigger the value, the newer the reaction.
	//
	// Use SetChosenOrder and GetChosenOrder helpers.
	ChosenOrder int
	// The reaction.
	Reaction ReactionClass
	// Number of users that reacted with this emoji.
	Count int
}

// ReactionCountTypeID is TL type id of ReactionCount.
const ReactionCountTypeID = 0xa3d1cb80

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

func ( *ReactionCount) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ChosenOrder == 0) {
		return false
	}
	if !(.Reaction == nil) {
		return false
	}
	if !(.Count == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ReactionCount from given interface.
func ( *ReactionCount) ( interface {
	() ( int,  bool)
	() ( ReactionClass)
	() ( int)
}) {
	if ,  := .();  {
		.ChosenOrder = 
	}

	.Reaction = .()
	.Count = .()
}

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

// TypeName returns name of type in TL schema.
func (*ReactionCount) () string {
	return "reactionCount"
}

// TypeInfo returns info about TL type.
func ( *ReactionCount) () tdp.Type {
	 := tdp.Type{
		Name: "reactionCount",
		ID:   ReactionCountTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChosenOrder",
			SchemaName: "chosen_order",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *ReactionCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionCount#a3d1cb80 as nil")
	}
	.PutID(ReactionCountTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReactionCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionCount#a3d1cb80 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.ChosenOrder)
	}
	if .Reaction == nil {
		return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field reaction is nil")
	}
	if  := .Reaction.Encode();  != nil {
		return fmt.Errorf("unable to encode reactionCount#a3d1cb80: field reaction: %w", )
	}
	.PutInt(.Count)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ReactionCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionCount#a3d1cb80 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field chosen_order: %w", )
		}
		.ChosenOrder = 
	}
	{
		,  := DecodeReaction()
		if  != nil {
			return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field reaction: %w", )
		}
		.Reaction = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode reactionCount#a3d1cb80: field count: %w", )
		}
		.Count = 
	}
	return nil
}

// SetChosenOrder sets value of ChosenOrder conditional field.
func ( *ReactionCount) ( int) {
	.Flags.Set(0)
	.ChosenOrder = 
}

// GetChosenOrder returns value of ChosenOrder conditional field and
// boolean which is true if field was set.
func ( *ReactionCount) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ChosenOrder, true
}

// GetReaction returns value of Reaction field.
func ( *ReactionCount) () ( ReactionClass) {
	if  == nil {
		return
	}
	return .Reaction
}

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