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

// MessagesReactionsNotModified represents TL type `messages.reactionsNotModified#b06fdbdf`.
// The server-side list of message reactions¹ hasn't changed
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/constructor/messages.reactionsNotModified for reference.
type MessagesReactionsNotModified struct {
}

// MessagesReactionsNotModifiedTypeID is TL type id of MessagesReactionsNotModified.
const MessagesReactionsNotModifiedTypeID = 0xb06fdbdf

// construct implements constructor of MessagesReactionsClass.
func ( MessagesReactionsNotModified) () MessagesReactionsClass { return & }

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

	_ MessagesReactionsClass = &MessagesReactionsNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesReactionsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reactionsNotModified#b06fdbdf as nil")
	}
	.PutID(MessagesReactionsNotModifiedTypeID)
	return .EncodeBare()
}

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

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

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

// MessagesReactions represents TL type `messages.reactions#eafdf716`.
// List of message reactions¹
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/constructor/messages.reactions for reference.
type MessagesReactions struct {
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// Reactions
	Reactions []ReactionClass
}

// MessagesReactionsTypeID is TL type id of MessagesReactions.
const MessagesReactionsTypeID = 0xeafdf716

// construct implements constructor of MessagesReactionsClass.
func ( MessagesReactions) () MessagesReactionsClass { return & }

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

	_ MessagesReactionsClass = &MessagesReactions{}
)

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

	return true
}

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

// FillFrom fills MessagesReactions from given interface.
func ( *MessagesReactions) ( interface {
	() ( int64)
	() ( []ReactionClass)
}) {
	.Hash = .()
	.Reactions = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.reactions#eafdf716 as nil")
	}
	.PutID(MessagesReactionsTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// MapReactions returns field Reactions wrapped in ReactionClassArray helper.
func ( *MessagesReactions) () ( ReactionClassArray) {
	return ReactionClassArray(.Reactions)
}

// MessagesReactionsClassName is schema name of MessagesReactionsClass.
const MessagesReactionsClassName = "messages.Reactions"

// MessagesReactionsClass represents messages.Reactions generic type.
//
// See https://core.telegram.org/type/messages.Reactions for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesReactions(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesReactionsNotModified: // messages.reactionsNotModified#b06fdbdf
//	case *tg.MessagesReactions: // messages.reactions#eafdf716
//	default: panic(v)
//	}
type MessagesReactionsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesReactionsClass

	// 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 MessagesReactionsClass to MessagesReactions.
	AsModified() (*MessagesReactions, bool)
}

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

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

// DecodeMessagesReactions implements binary de-serialization for MessagesReactionsClass.
func ( *bin.Buffer) (MessagesReactionsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesReactionsNotModifiedTypeID:
		// Decoding messages.reactionsNotModified#b06fdbdf.
		 := MessagesReactionsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", )
		}
		return &, nil
	case MessagesReactionsTypeID:
		// Decoding messages.reactions#eafdf716.
		 := MessagesReactions{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesReactionsClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesReactions boxes the MessagesReactionsClass providing a helper.
type MessagesReactionsBox struct {
	Reactions MessagesReactionsClass
}

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

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