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

// StoryReaction represents TL type `storyReaction#6090d6d5`.
//
// See https://core.telegram.org/constructor/storyReaction for reference.
type StoryReaction struct {
	// PeerID field of StoryReaction.
	PeerID PeerClass
	// Date field of StoryReaction.
	Date int
	// Reaction field of StoryReaction.
	Reaction ReactionClass
}

// StoryReactionTypeID is TL type id of StoryReaction.
const StoryReactionTypeID = 0x6090d6d5

// construct implements constructor of StoryReactionClass.
func ( StoryReaction) () StoryReactionClass { return & }

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

	_ StoryReactionClass = &StoryReaction{}
)

func ( *StoryReaction) () bool {
	if  == nil {
		return true
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Reaction == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoryReaction from given interface.
func ( *StoryReaction) ( interface {
	() ( PeerClass)
	() ( int)
	() ( ReactionClass)
}) {
	.PeerID = .()
	.Date = .()
	.Reaction = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoryReaction) () tdp.Type {
	 := tdp.Type{
		Name: "storyReaction",
		ID:   StoryReactionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Reaction",
			SchemaName: "reaction",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoryReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReaction#6090d6d5 as nil")
	}
	.PutID(StoryReactionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReaction#6090d6d5 as nil")
	}
	if .PeerID == nil {
		return fmt.Errorf("unable to encode storyReaction#6090d6d5: field peer_id is nil")
	}
	if  := .PeerID.Encode();  != nil {
		return fmt.Errorf("unable to encode storyReaction#6090d6d5: field peer_id: %w", )
	}
	.PutInt(.Date)
	if .Reaction == nil {
		return fmt.Errorf("unable to encode storyReaction#6090d6d5: field reaction is nil")
	}
	if  := .Reaction.Encode();  != nil {
		return fmt.Errorf("unable to encode storyReaction#6090d6d5: field reaction: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryReaction) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyReaction#6090d6d5 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode storyReaction#6090d6d5: field peer_id: %w", )
		}
		.PeerID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode storyReaction#6090d6d5: field date: %w", )
		}
		.Date = 
	}
	{
		,  := DecodeReaction()
		if  != nil {
			return fmt.Errorf("unable to decode storyReaction#6090d6d5: field reaction: %w", )
		}
		.Reaction = 
	}
	return nil
}

// GetPeerID returns value of PeerID field.
func ( *StoryReaction) () ( PeerClass) {
	if  == nil {
		return
	}
	return .PeerID
}

// GetDate returns value of Date field.
func ( *StoryReaction) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

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

// StoryReactionPublicForward represents TL type `storyReactionPublicForward#bbab2643`.
//
// See https://core.telegram.org/constructor/storyReactionPublicForward for reference.
type StoryReactionPublicForward struct {
	// Message field of StoryReactionPublicForward.
	Message MessageClass
}

// StoryReactionPublicForwardTypeID is TL type id of StoryReactionPublicForward.
const StoryReactionPublicForwardTypeID = 0xbbab2643

// construct implements constructor of StoryReactionClass.
func ( StoryReactionPublicForward) () StoryReactionClass { return & }

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

	_ StoryReactionClass = &StoryReactionPublicForward{}
)

func ( *StoryReactionPublicForward) () bool {
	if  == nil {
		return true
	}
	if !(.Message == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoryReactionPublicForward from given interface.
func ( *StoryReactionPublicForward) ( interface {
	() ( MessageClass)
}) {
	.Message = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoryReactionPublicForward) () tdp.Type {
	 := tdp.Type{
		Name: "storyReactionPublicForward",
		ID:   StoryReactionPublicForwardTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Message",
			SchemaName: "message",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoryReactionPublicForward) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReactionPublicForward#bbab2643 as nil")
	}
	.PutID(StoryReactionPublicForwardTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryReactionPublicForward) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReactionPublicForward#bbab2643 as nil")
	}
	if .Message == nil {
		return fmt.Errorf("unable to encode storyReactionPublicForward#bbab2643: field message is nil")
	}
	if  := .Message.Encode();  != nil {
		return fmt.Errorf("unable to encode storyReactionPublicForward#bbab2643: field message: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryReactionPublicForward) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyReactionPublicForward#bbab2643 to nil")
	}
	{
		,  := DecodeMessage()
		if  != nil {
			return fmt.Errorf("unable to decode storyReactionPublicForward#bbab2643: field message: %w", )
		}
		.Message = 
	}
	return nil
}

// GetMessage returns value of Message field.
func ( *StoryReactionPublicForward) () ( MessageClass) {
	if  == nil {
		return
	}
	return .Message
}

// StoryReactionPublicRepost represents TL type `storyReactionPublicRepost#cfcd0f13`.
//
// See https://core.telegram.org/constructor/storyReactionPublicRepost for reference.
type StoryReactionPublicRepost struct {
	// PeerID field of StoryReactionPublicRepost.
	PeerID PeerClass
	// Story field of StoryReactionPublicRepost.
	Story StoryItemClass
}

// StoryReactionPublicRepostTypeID is TL type id of StoryReactionPublicRepost.
const StoryReactionPublicRepostTypeID = 0xcfcd0f13

// construct implements constructor of StoryReactionClass.
func ( StoryReactionPublicRepost) () StoryReactionClass { return & }

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

	_ StoryReactionClass = &StoryReactionPublicRepost{}
)

func ( *StoryReactionPublicRepost) () bool {
	if  == nil {
		return true
	}
	if !(.PeerID == nil) {
		return false
	}
	if !(.Story == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoryReactionPublicRepost from given interface.
func ( *StoryReactionPublicRepost) ( interface {
	() ( PeerClass)
	() ( StoryItemClass)
}) {
	.PeerID = .()
	.Story = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoryReactionPublicRepost) () tdp.Type {
	 := tdp.Type{
		Name: "storyReactionPublicRepost",
		ID:   StoryReactionPublicRepostTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PeerID",
			SchemaName: "peer_id",
		},
		{
			Name:       "Story",
			SchemaName: "story",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoryReactionPublicRepost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReactionPublicRepost#cfcd0f13 as nil")
	}
	.PutID(StoryReactionPublicRepostTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoryReactionPublicRepost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode storyReactionPublicRepost#cfcd0f13 as nil")
	}
	if .PeerID == nil {
		return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field peer_id is nil")
	}
	if  := .PeerID.Encode();  != nil {
		return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field peer_id: %w", )
	}
	if .Story == nil {
		return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field story is nil")
	}
	if  := .Story.Encode();  != nil {
		return fmt.Errorf("unable to encode storyReactionPublicRepost#cfcd0f13: field story: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoryReactionPublicRepost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode storyReactionPublicRepost#cfcd0f13 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode storyReactionPublicRepost#cfcd0f13: field peer_id: %w", )
		}
		.PeerID = 
	}
	{
		,  := DecodeStoryItem()
		if  != nil {
			return fmt.Errorf("unable to decode storyReactionPublicRepost#cfcd0f13: field story: %w", )
		}
		.Story = 
	}
	return nil
}

// GetPeerID returns value of PeerID field.
func ( *StoryReactionPublicRepost) () ( PeerClass) {
	if  == nil {
		return
	}
	return .PeerID
}

// GetStory returns value of Story field.
func ( *StoryReactionPublicRepost) () ( StoryItemClass) {
	if  == nil {
		return
	}
	return .Story
}

// StoryReactionClassName is schema name of StoryReactionClass.
const StoryReactionClassName = "StoryReaction"

// StoryReactionClass represents StoryReaction generic type.
//
// See https://core.telegram.org/type/StoryReaction for reference.
//
// Example:
//
//	g, err := tg.DecodeStoryReaction(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StoryReaction: // storyReaction#6090d6d5
//	case *tg.StoryReactionPublicForward: // storyReactionPublicForward#bbab2643
//	case *tg.StoryReactionPublicRepost: // storyReactionPublicRepost#cfcd0f13
//	default: panic(v)
//	}
type StoryReactionClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StoryReactionClass

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

// DecodeStoryReaction implements binary de-serialization for StoryReactionClass.
func ( *bin.Buffer) (StoryReactionClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StoryReactionTypeID:
		// Decoding storyReaction#6090d6d5.
		 := StoryReaction{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", )
		}
		return &, nil
	case StoryReactionPublicForwardTypeID:
		// Decoding storyReactionPublicForward#bbab2643.
		 := StoryReactionPublicForward{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", )
		}
		return &, nil
	case StoryReactionPublicRepostTypeID:
		// Decoding storyReactionPublicRepost#cfcd0f13.
		 := StoryReactionPublicRepost{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StoryReactionClass: %w", bin.NewUnexpectedID())
	}
}

// StoryReaction boxes the StoryReactionClass providing a helper.
type StoryReactionBox struct {
	StoryReaction StoryReactionClass
}

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

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