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

// MessagesFeaturedStickersNotModified represents TL type `messages.featuredStickersNotModified#c6dc0c66`.
// Featured stickers haven't changed
//
// See https://core.telegram.org/constructor/messages.featuredStickersNotModified for reference.
type MessagesFeaturedStickersNotModified struct {
	// Total number of featured stickers
	Count int
}

// MessagesFeaturedStickersNotModifiedTypeID is TL type id of MessagesFeaturedStickersNotModified.
const MessagesFeaturedStickersNotModifiedTypeID = 0xc6dc0c66

// construct implements constructor of MessagesFeaturedStickersClass.
func ( MessagesFeaturedStickersNotModified) () MessagesFeaturedStickersClass { return & }

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

	_ MessagesFeaturedStickersClass = &MessagesFeaturedStickersNotModified{}
)

func ( *MessagesFeaturedStickersNotModified) () bool {
	if  == nil {
		return true
	}
	if !(.Count == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesFeaturedStickersNotModified from given interface.
func ( *MessagesFeaturedStickersNotModified) ( interface {
	() ( int)
}) {
	.Count = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesFeaturedStickersNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "messages.featuredStickersNotModified",
		ID:   MessagesFeaturedStickersNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesFeaturedStickersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.featuredStickersNotModified#c6dc0c66 as nil")
	}
	.PutID(MessagesFeaturedStickersNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesFeaturedStickersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.featuredStickersNotModified#c6dc0c66 as nil")
	}
	.PutInt(.Count)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesFeaturedStickersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.featuredStickersNotModified#c6dc0c66 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickersNotModified#c6dc0c66: field count: %w", )
		}
		.Count = 
	}
	return nil
}

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

// MessagesFeaturedStickers represents TL type `messages.featuredStickers#be382906`.
// Featured stickersets
//
// See https://core.telegram.org/constructor/messages.featuredStickers for reference.
type MessagesFeaturedStickers struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a premium stickerset
	Premium bool
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// Total number of featured stickers
	Count int
	// Featured stickersets
	Sets []StickerSetCoveredClass
	// IDs of new featured stickersets
	Unread []int64
}

// MessagesFeaturedStickersTypeID is TL type id of MessagesFeaturedStickers.
const MessagesFeaturedStickersTypeID = 0xbe382906

// construct implements constructor of MessagesFeaturedStickersClass.
func ( MessagesFeaturedStickers) () MessagesFeaturedStickersClass { return & }

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

	_ MessagesFeaturedStickersClass = &MessagesFeaturedStickers{}
)

func ( *MessagesFeaturedStickers) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Premium == false) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Sets == nil) {
		return false
	}
	if !(.Unread == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesFeaturedStickers from given interface.
func ( *MessagesFeaturedStickers) ( interface {
	() ( bool)
	() ( int64)
	() ( int)
	() ( []StickerSetCoveredClass)
	() ( []int64)
}) {
	.Premium = .()
	.Hash = .()
	.Count = .()
	.Sets = .()
	.Unread = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesFeaturedStickers) () tdp.Type {
	 := tdp.Type{
		Name: "messages.featuredStickers",
		ID:   MessagesFeaturedStickersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Premium",
			SchemaName: "premium",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Sets",
			SchemaName: "sets",
		},
		{
			Name:       "Unread",
			SchemaName: "unread",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesFeaturedStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.featuredStickers#be382906 as nil")
	}
	.PutID(MessagesFeaturedStickersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesFeaturedStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.featuredStickers#be382906 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.featuredStickers#be382906: field flags: %w", )
	}
	.PutLong(.Hash)
	.PutInt(.Count)
	.PutVectorHeader(len(.Sets))
	for ,  := range .Sets {
		if  == nil {
			return fmt.Errorf("unable to encode messages.featuredStickers#be382906: field sets element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.featuredStickers#be382906: field sets element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Unread))
	for ,  := range .Unread {
		.PutLong()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesFeaturedStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.featuredStickers#be382906 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field flags: %w", )
		}
	}
	.Premium = .Flags.Has(0)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field sets: %w", )
		}

		if  > 0 {
			.Sets = make([]StickerSetCoveredClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStickerSetCovered()
			if  != nil {
				return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field sets: %w", )
			}
			.Sets = append(.Sets, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field unread: %w", )
		}

		if  > 0 {
			.Unread = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode messages.featuredStickers#be382906: field unread: %w", )
			}
			.Unread = append(.Unread, )
		}
	}
	return nil
}

// SetPremium sets value of Premium conditional field.
func ( *MessagesFeaturedStickers) ( bool) {
	if  {
		.Flags.Set(0)
		.Premium = true
	} else {
		.Flags.Unset(0)
		.Premium = false
	}
}

// GetPremium returns value of Premium conditional field.
func ( *MessagesFeaturedStickers) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

// GetSets returns value of Sets field.
func ( *MessagesFeaturedStickers) () ( []StickerSetCoveredClass) {
	if  == nil {
		return
	}
	return .Sets
}

// GetUnread returns value of Unread field.
func ( *MessagesFeaturedStickers) () ( []int64) {
	if  == nil {
		return
	}
	return .Unread
}

// MapSets returns field Sets wrapped in StickerSetCoveredClassArray helper.
func ( *MessagesFeaturedStickers) () ( StickerSetCoveredClassArray) {
	return StickerSetCoveredClassArray(.Sets)
}

// MessagesFeaturedStickersClassName is schema name of MessagesFeaturedStickersClass.
const MessagesFeaturedStickersClassName = "messages.FeaturedStickers"

// MessagesFeaturedStickersClass represents messages.FeaturedStickers generic type.
//
// See https://core.telegram.org/type/messages.FeaturedStickers for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesFeaturedStickers(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesFeaturedStickersNotModified: // messages.featuredStickersNotModified#c6dc0c66
//	case *tg.MessagesFeaturedStickers: // messages.featuredStickers#be382906
//	default: panic(v)
//	}
type MessagesFeaturedStickersClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesFeaturedStickersClass

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

	// Total number of featured stickers
	GetCount() (value int)

	// AsModified tries to map MessagesFeaturedStickersClass to MessagesFeaturedStickers.
	AsModified() (*MessagesFeaturedStickers, bool)
}

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

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

// DecodeMessagesFeaturedStickers implements binary de-serialization for MessagesFeaturedStickersClass.
func ( *bin.Buffer) (MessagesFeaturedStickersClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesFeaturedStickersNotModifiedTypeID:
		// Decoding messages.featuredStickersNotModified#c6dc0c66.
		 := MessagesFeaturedStickersNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesFeaturedStickersClass: %w", )
		}
		return &, nil
	case MessagesFeaturedStickersTypeID:
		// Decoding messages.featuredStickers#be382906.
		 := MessagesFeaturedStickers{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesFeaturedStickersClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesFeaturedStickersClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesFeaturedStickers boxes the MessagesFeaturedStickersClass providing a helper.
type MessagesFeaturedStickersBox struct {
	FeaturedStickers MessagesFeaturedStickersClass
}

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

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