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

// StatsMessageStats represents TL type `stats.messageStats#7fe91c14`.
// Message statistics
//
// See https://core.telegram.org/constructor/stats.messageStats for reference.
type StatsMessageStats struct {
	// Message view graph
	ViewsGraph StatsGraphClass
	// A graph containing the number of reactions on stories categorized by emotion
	ReactionsByEmotionGraph StatsGraphClass
}

// StatsMessageStatsTypeID is TL type id of StatsMessageStats.
const StatsMessageStatsTypeID = 0x7fe91c14

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

func ( *StatsMessageStats) () bool {
	if  == nil {
		return true
	}
	if !(.ViewsGraph == nil) {
		return false
	}
	if !(.ReactionsByEmotionGraph == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StatsMessageStats from given interface.
func ( *StatsMessageStats) ( interface {
	() ( StatsGraphClass)
	() ( StatsGraphClass)
}) {
	.ViewsGraph = .()
	.ReactionsByEmotionGraph = .()
}

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

// TypeName returns name of type in TL schema.
func (*StatsMessageStats) () string {
	return "stats.messageStats"
}

// TypeInfo returns info about TL type.
func ( *StatsMessageStats) () tdp.Type {
	 := tdp.Type{
		Name: "stats.messageStats",
		ID:   StatsMessageStatsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ViewsGraph",
			SchemaName: "views_graph",
		},
		{
			Name:       "ReactionsByEmotionGraph",
			SchemaName: "reactions_by_emotion_graph",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StatsMessageStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.messageStats#7fe91c14 as nil")
	}
	.PutID(StatsMessageStatsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsMessageStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.messageStats#7fe91c14 as nil")
	}
	if .ViewsGraph == nil {
		return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field views_graph is nil")
	}
	if  := .ViewsGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field views_graph: %w", )
	}
	if .ReactionsByEmotionGraph == nil {
		return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field reactions_by_emotion_graph is nil")
	}
	if  := .ReactionsByEmotionGraph.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.messageStats#7fe91c14: field reactions_by_emotion_graph: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsMessageStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.messageStats#7fe91c14 to nil")
	}
	if  := .ConsumeID(StatsMessageStatsTypeID);  != nil {
		return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsMessageStats) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.messageStats#7fe91c14 to nil")
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: field views_graph: %w", )
		}
		.ViewsGraph = 
	}
	{
		,  := DecodeStatsGraph()
		if  != nil {
			return fmt.Errorf("unable to decode stats.messageStats#7fe91c14: field reactions_by_emotion_graph: %w", )
		}
		.ReactionsByEmotionGraph = 
	}
	return nil
}

// GetViewsGraph returns value of ViewsGraph field.
func ( *StatsMessageStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .ViewsGraph
}

// GetReactionsByEmotionGraph returns value of ReactionsByEmotionGraph field.
func ( *StatsMessageStats) () ( StatsGraphClass) {
	if  == nil {
		return
	}
	return .ReactionsByEmotionGraph
}