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

// MessagesAvailableReactionsNotModified represents TL type `messages.availableReactionsNotModified#9f071957`.
// No new reactions are available
//
// See https://core.telegram.org/constructor/messages.availableReactionsNotModified for reference.
type MessagesAvailableReactionsNotModified struct {
}

// MessagesAvailableReactionsNotModifiedTypeID is TL type id of MessagesAvailableReactionsNotModified.
const MessagesAvailableReactionsNotModifiedTypeID = 0x9f071957

// construct implements constructor of MessagesAvailableReactionsClass.
func ( MessagesAvailableReactionsNotModified) () MessagesAvailableReactionsClass { return & }

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

	_ MessagesAvailableReactionsClass = &MessagesAvailableReactionsNotModified{}
)

func ( *MessagesAvailableReactionsNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesAvailableReactionsNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "messages.availableReactionsNotModified",
		ID:   MessagesAvailableReactionsNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesAvailableReactionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.availableReactionsNotModified#9f071957 as nil")
	}
	.PutID(MessagesAvailableReactionsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesAvailableReactionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.availableReactionsNotModified#9f071957 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesAvailableReactionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.availableReactionsNotModified#9f071957 to nil")
	}
	return nil
}

// MessagesAvailableReactions represents TL type `messages.availableReactions#768e3aad`.
// Animations and metadata associated with message reactions »¹
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/constructor/messages.availableReactions for reference.
type MessagesAvailableReactions struct {
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
	// Animations and metadata associated with message reactions »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/reactions
	Reactions []AvailableReaction
}

// MessagesAvailableReactionsTypeID is TL type id of MessagesAvailableReactions.
const MessagesAvailableReactionsTypeID = 0x768e3aad

// construct implements constructor of MessagesAvailableReactionsClass.
func ( MessagesAvailableReactions) () MessagesAvailableReactionsClass { return & }

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

	_ MessagesAvailableReactionsClass = &MessagesAvailableReactions{}
)

func ( *MessagesAvailableReactions) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Reactions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesAvailableReactions from given interface.
func ( *MessagesAvailableReactions) ( interface {
	() ( int)
	() ( []AvailableReaction)
}) {
	.Hash = .()
	.Reactions = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesAvailableReactions) () tdp.Type {
	 := tdp.Type{
		Name: "messages.availableReactions",
		ID:   MessagesAvailableReactionsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesAvailableReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.availableReactions#768e3aad as nil")
	}
	.PutID(MessagesAvailableReactionsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesAvailableReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.availableReactions#768e3aad as nil")
	}
	.PutInt(.Hash)
	.PutVectorHeader(len(.Reactions))
	for ,  := range .Reactions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.availableReactions#768e3aad: field reactions element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesAvailableReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.availableReactions#768e3aad to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.availableReactions#768e3aad: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.availableReactions#768e3aad: field reactions: %w", )
		}

		if  > 0 {
			.Reactions = make([]AvailableReaction, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AvailableReaction
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.availableReactions#768e3aad: field reactions: %w", )
			}
			.Reactions = append(.Reactions, )
		}
	}
	return nil
}

// GetHash returns value of Hash field.
func ( *MessagesAvailableReactions) () ( int) {
	if  == nil {
		return
	}
	return .Hash
}

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

// MessagesAvailableReactionsClassName is schema name of MessagesAvailableReactionsClass.
const MessagesAvailableReactionsClassName = "messages.AvailableReactions"

// MessagesAvailableReactionsClass represents messages.AvailableReactions generic type.
//
// See https://core.telegram.org/type/messages.AvailableReactions for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesAvailableReactions(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesAvailableReactionsNotModified: // messages.availableReactionsNotModified#9f071957
//	case *tg.MessagesAvailableReactions: // messages.availableReactions#768e3aad
//	default: panic(v)
//	}
type MessagesAvailableReactionsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesAvailableReactionsClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsModified tries to map MessagesAvailableReactionsClass to MessagesAvailableReactions.
	AsModified() (*MessagesAvailableReactions, bool)
}

// AsModified tries to map MessagesAvailableReactionsNotModified to MessagesAvailableReactions.
func ( *MessagesAvailableReactionsNotModified) () (*MessagesAvailableReactions, bool) {
	return nil, false
}

// AsModified tries to map MessagesAvailableReactions to MessagesAvailableReactions.
func ( *MessagesAvailableReactions) () (*MessagesAvailableReactions, bool) {
	return , true
}

// DecodeMessagesAvailableReactions implements binary de-serialization for MessagesAvailableReactionsClass.
func ( *bin.Buffer) (MessagesAvailableReactionsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesAvailableReactionsNotModifiedTypeID:
		// Decoding messages.availableReactionsNotModified#9f071957.
		 := MessagesAvailableReactionsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesAvailableReactionsClass: %w", )
		}
		return &, nil
	case MessagesAvailableReactionsTypeID:
		// Decoding messages.availableReactions#768e3aad.
		 := MessagesAvailableReactions{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesAvailableReactionsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesAvailableReactionsClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesAvailableReactions boxes the MessagesAvailableReactionsClass providing a helper.
type MessagesAvailableReactionsBox struct {
	AvailableReactions MessagesAvailableReactionsClass
}

// Decode implements bin.Decoder for MessagesAvailableReactionsBox.
func ( *MessagesAvailableReactionsBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode MessagesAvailableReactionsBox to nil")
	}
	,  := DecodeMessagesAvailableReactions()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.AvailableReactions = 
	return nil
}

// Encode implements bin.Encode for MessagesAvailableReactionsBox.
func ( *MessagesAvailableReactionsBox) ( *bin.Buffer) error {
	if  == nil || .AvailableReactions == nil {
		return fmt.Errorf("unable to encode MessagesAvailableReactionsClass as nil")
	}
	return .AvailableReactions.Encode()
}