// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// PremiumLimitTypeSupergroupCount represents TL type `premiumLimitTypeSupergroupCount#f13ff385`.
type PremiumLimitTypeSupergroupCount struct {
}

// PremiumLimitTypeSupergroupCountTypeID is TL type id of PremiumLimitTypeSupergroupCount.
const PremiumLimitTypeSupergroupCountTypeID = 0xf13ff385

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeSupergroupCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeSupergroupCount{}
)

func (p *PremiumLimitTypeSupergroupCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeSupergroupCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeSupergroupCount",
		ID:   PremiumLimitTypeSupergroupCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeSupergroupCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSupergroupCount#f13ff385 as nil")
	}
	b.PutID(PremiumLimitTypeSupergroupCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeSupergroupCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSupergroupCount#f13ff385 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeSupergroupCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSupergroupCount#f13ff385 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeSupergroupCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeSupergroupCount#f13ff385: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeSupergroupCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSupergroupCount#f13ff385 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeSupergroupCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSupergroupCount#f13ff385 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeSupergroupCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeSupergroupCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSupergroupCount#f13ff385 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeSupergroupCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeSupergroupCount#f13ff385: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypePinnedChatCount represents TL type `premiumLimitTypePinnedChatCount#c47543e1`.
type PremiumLimitTypePinnedChatCount struct {
}

// PremiumLimitTypePinnedChatCountTypeID is TL type id of PremiumLimitTypePinnedChatCount.
const PremiumLimitTypePinnedChatCountTypeID = 0xc47543e1

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypePinnedChatCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypePinnedChatCount{}
)

func (p *PremiumLimitTypePinnedChatCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypePinnedChatCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypePinnedChatCount",
		ID:   PremiumLimitTypePinnedChatCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypePinnedChatCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedChatCount#c47543e1 as nil")
	}
	b.PutID(PremiumLimitTypePinnedChatCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypePinnedChatCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedChatCount#c47543e1 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypePinnedChatCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedChatCount#c47543e1 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypePinnedChatCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypePinnedChatCount#c47543e1: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypePinnedChatCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedChatCount#c47543e1 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypePinnedChatCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedChatCount#c47543e1 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypePinnedChatCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypePinnedChatCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedChatCount#c47543e1 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypePinnedChatCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypePinnedChatCount#c47543e1: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeCreatedPublicChatCount represents TL type `premiumLimitTypeCreatedPublicChatCount#1a96beb9`.
type PremiumLimitTypeCreatedPublicChatCount struct {
}

// PremiumLimitTypeCreatedPublicChatCountTypeID is TL type id of PremiumLimitTypeCreatedPublicChatCount.
const PremiumLimitTypeCreatedPublicChatCountTypeID = 0x1a96beb9

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeCreatedPublicChatCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeCreatedPublicChatCount{}
)

func (p *PremiumLimitTypeCreatedPublicChatCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeCreatedPublicChatCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeCreatedPublicChatCount",
		ID:   PremiumLimitTypeCreatedPublicChatCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCreatedPublicChatCount#1a96beb9 as nil")
	}
	b.PutID(PremiumLimitTypeCreatedPublicChatCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCreatedPublicChatCount#1a96beb9 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCreatedPublicChatCount#1a96beb9 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeCreatedPublicChatCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeCreatedPublicChatCount#1a96beb9: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCreatedPublicChatCount#1a96beb9 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCreatedPublicChatCount#1a96beb9 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeCreatedPublicChatCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeCreatedPublicChatCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCreatedPublicChatCount#1a96beb9 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeCreatedPublicChatCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeCreatedPublicChatCount#1a96beb9: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeSavedAnimationCount represents TL type `premiumLimitTypeSavedAnimationCount#fed27d89`.
type PremiumLimitTypeSavedAnimationCount struct {
}

// PremiumLimitTypeSavedAnimationCountTypeID is TL type id of PremiumLimitTypeSavedAnimationCount.
const PremiumLimitTypeSavedAnimationCountTypeID = 0xfed27d89

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeSavedAnimationCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeSavedAnimationCount{}
)

func (p *PremiumLimitTypeSavedAnimationCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeSavedAnimationCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeSavedAnimationCount",
		ID:   PremiumLimitTypeSavedAnimationCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeSavedAnimationCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSavedAnimationCount#fed27d89 as nil")
	}
	b.PutID(PremiumLimitTypeSavedAnimationCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeSavedAnimationCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSavedAnimationCount#fed27d89 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeSavedAnimationCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSavedAnimationCount#fed27d89 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeSavedAnimationCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeSavedAnimationCount#fed27d89: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeSavedAnimationCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSavedAnimationCount#fed27d89 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeSavedAnimationCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSavedAnimationCount#fed27d89 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeSavedAnimationCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeSavedAnimationCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSavedAnimationCount#fed27d89 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeSavedAnimationCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeSavedAnimationCount#fed27d89: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeFavoriteStickerCount represents TL type `premiumLimitTypeFavoriteStickerCount#2621e223`.
type PremiumLimitTypeFavoriteStickerCount struct {
}

// PremiumLimitTypeFavoriteStickerCountTypeID is TL type id of PremiumLimitTypeFavoriteStickerCount.
const PremiumLimitTypeFavoriteStickerCountTypeID = 0x2621e223

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeFavoriteStickerCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeFavoriteStickerCount{}
)

func (p *PremiumLimitTypeFavoriteStickerCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeFavoriteStickerCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeFavoriteStickerCount",
		ID:   PremiumLimitTypeFavoriteStickerCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeFavoriteStickerCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeFavoriteStickerCount#2621e223 as nil")
	}
	b.PutID(PremiumLimitTypeFavoriteStickerCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeFavoriteStickerCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeFavoriteStickerCount#2621e223 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeFavoriteStickerCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeFavoriteStickerCount#2621e223 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeFavoriteStickerCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeFavoriteStickerCount#2621e223: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeFavoriteStickerCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeFavoriteStickerCount#2621e223 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeFavoriteStickerCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeFavoriteStickerCount#2621e223 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeFavoriteStickerCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeFavoriteStickerCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeFavoriteStickerCount#2621e223 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeFavoriteStickerCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeFavoriteStickerCount#2621e223: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeChatFolderCount represents TL type `premiumLimitTypeChatFolderCount#1680096e`.
type PremiumLimitTypeChatFolderCount struct {
}

// PremiumLimitTypeChatFolderCountTypeID is TL type id of PremiumLimitTypeChatFolderCount.
const PremiumLimitTypeChatFolderCountTypeID = 0x1680096e

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeChatFolderCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeChatFolderCount{}
)

func (p *PremiumLimitTypeChatFolderCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeChatFolderCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeChatFolderCount",
		ID:   PremiumLimitTypeChatFolderCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeChatFolderCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderCount#1680096e as nil")
	}
	b.PutID(PremiumLimitTypeChatFolderCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeChatFolderCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderCount#1680096e as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeChatFolderCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderCount#1680096e to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeChatFolderCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeChatFolderCount#1680096e: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeChatFolderCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderCount#1680096e to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeChatFolderCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderCount#1680096e as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeChatFolderCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeChatFolderCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderCount#1680096e to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeChatFolderCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeChatFolderCount#1680096e: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeChatFolderChosenChatCount represents TL type `premiumLimitTypeChatFolderChosenChatCount#64d14355`.
type PremiumLimitTypeChatFolderChosenChatCount struct {
}

// PremiumLimitTypeChatFolderChosenChatCountTypeID is TL type id of PremiumLimitTypeChatFolderChosenChatCount.
const PremiumLimitTypeChatFolderChosenChatCountTypeID = 0x64d14355

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeChatFolderChosenChatCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeChatFolderChosenChatCount{}
)

func (p *PremiumLimitTypeChatFolderChosenChatCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeChatFolderChosenChatCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeChatFolderChosenChatCount",
		ID:   PremiumLimitTypeChatFolderChosenChatCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderChosenChatCount#64d14355 as nil")
	}
	b.PutID(PremiumLimitTypeChatFolderChosenChatCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderChosenChatCount#64d14355 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderChosenChatCount#64d14355 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeChatFolderChosenChatCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeChatFolderChosenChatCount#64d14355: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderChosenChatCount#64d14355 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderChosenChatCount#64d14355 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeChatFolderChosenChatCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeChatFolderChosenChatCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderChosenChatCount#64d14355 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeChatFolderChosenChatCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeChatFolderChosenChatCount#64d14355: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypePinnedArchivedChatCount represents TL type `premiumLimitTypePinnedArchivedChatCount#588b2a0c`.
type PremiumLimitTypePinnedArchivedChatCount struct {
}

// PremiumLimitTypePinnedArchivedChatCountTypeID is TL type id of PremiumLimitTypePinnedArchivedChatCount.
const PremiumLimitTypePinnedArchivedChatCountTypeID = 0x588b2a0c

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypePinnedArchivedChatCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypePinnedArchivedChatCount{}
)

func (p *PremiumLimitTypePinnedArchivedChatCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypePinnedArchivedChatCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypePinnedArchivedChatCount",
		ID:   PremiumLimitTypePinnedArchivedChatCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedArchivedChatCount#588b2a0c as nil")
	}
	b.PutID(PremiumLimitTypePinnedArchivedChatCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedArchivedChatCount#588b2a0c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedArchivedChatCount#588b2a0c to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypePinnedArchivedChatCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypePinnedArchivedChatCount#588b2a0c: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedArchivedChatCount#588b2a0c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedArchivedChatCount#588b2a0c as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypePinnedArchivedChatCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypePinnedArchivedChatCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedArchivedChatCount#588b2a0c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypePinnedArchivedChatCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypePinnedArchivedChatCount#588b2a0c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypePinnedSavedMessagesTopicCount represents TL type `premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df`.
type PremiumLimitTypePinnedSavedMessagesTopicCount struct {
}

// PremiumLimitTypePinnedSavedMessagesTopicCountTypeID is TL type id of PremiumLimitTypePinnedSavedMessagesTopicCount.
const PremiumLimitTypePinnedSavedMessagesTopicCountTypeID = 0xa3eb64df

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypePinnedSavedMessagesTopicCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypePinnedSavedMessagesTopicCount{}
)

func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypePinnedSavedMessagesTopicCount",
		ID:   PremiumLimitTypePinnedSavedMessagesTopicCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df as nil")
	}
	b.PutID(PremiumLimitTypePinnedSavedMessagesTopicCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypePinnedSavedMessagesTopicCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypePinnedSavedMessagesTopicCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypePinnedSavedMessagesTopicCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypePinnedSavedMessagesTopicCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeCaptionLength represents TL type `premiumLimitTypeCaptionLength#1185d83a`.
type PremiumLimitTypeCaptionLength struct {
}

// PremiumLimitTypeCaptionLengthTypeID is TL type id of PremiumLimitTypeCaptionLength.
const PremiumLimitTypeCaptionLengthTypeID = 0x1185d83a

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeCaptionLength) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeCaptionLength{}
)

func (p *PremiumLimitTypeCaptionLength) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeCaptionLength) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeCaptionLength",
		ID:   PremiumLimitTypeCaptionLengthTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeCaptionLength) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCaptionLength#1185d83a as nil")
	}
	b.PutID(PremiumLimitTypeCaptionLengthTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeCaptionLength) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCaptionLength#1185d83a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeCaptionLength) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCaptionLength#1185d83a to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeCaptionLengthTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeCaptionLength#1185d83a: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeCaptionLength) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCaptionLength#1185d83a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeCaptionLength) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeCaptionLength#1185d83a as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeCaptionLength")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeCaptionLength) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeCaptionLength#1185d83a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeCaptionLength"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeCaptionLength#1185d83a: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeBioLength represents TL type `premiumLimitTypeBioLength#bba28603`.
type PremiumLimitTypeBioLength struct {
}

// PremiumLimitTypeBioLengthTypeID is TL type id of PremiumLimitTypeBioLength.
const PremiumLimitTypeBioLengthTypeID = 0xbba28603

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeBioLength) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeBioLength{}
)

func (p *PremiumLimitTypeBioLength) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeBioLength) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeBioLength",
		ID:   PremiumLimitTypeBioLengthTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeBioLength) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeBioLength#bba28603 as nil")
	}
	b.PutID(PremiumLimitTypeBioLengthTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeBioLength) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeBioLength#bba28603 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeBioLength) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeBioLength#bba28603 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeBioLengthTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeBioLength#bba28603: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeBioLength) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeBioLength#bba28603 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeBioLength) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeBioLength#bba28603 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeBioLength")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeBioLength) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeBioLength#bba28603 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeBioLength"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeBioLength#bba28603: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeChatFolderInviteLinkCount represents TL type `premiumLimitTypeChatFolderInviteLinkCount#f854261a`.
type PremiumLimitTypeChatFolderInviteLinkCount struct {
}

// PremiumLimitTypeChatFolderInviteLinkCountTypeID is TL type id of PremiumLimitTypeChatFolderInviteLinkCount.
const PremiumLimitTypeChatFolderInviteLinkCountTypeID = 0xf854261a

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeChatFolderInviteLinkCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeChatFolderInviteLinkCount{}
)

func (p *PremiumLimitTypeChatFolderInviteLinkCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeChatFolderInviteLinkCount",
		ID:   PremiumLimitTypeChatFolderInviteLinkCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderInviteLinkCount#f854261a as nil")
	}
	b.PutID(PremiumLimitTypeChatFolderInviteLinkCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderInviteLinkCount#f854261a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderInviteLinkCount#f854261a to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeChatFolderInviteLinkCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeChatFolderInviteLinkCount#f854261a: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderInviteLinkCount#f854261a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeChatFolderInviteLinkCount#f854261a as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeChatFolderInviteLinkCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeChatFolderInviteLinkCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeChatFolderInviteLinkCount#f854261a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeChatFolderInviteLinkCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeChatFolderInviteLinkCount#f854261a: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeShareableChatFolderCount represents TL type `premiumLimitTypeShareableChatFolderCount#601eb4c7`.
type PremiumLimitTypeShareableChatFolderCount struct {
}

// PremiumLimitTypeShareableChatFolderCountTypeID is TL type id of PremiumLimitTypeShareableChatFolderCount.
const PremiumLimitTypeShareableChatFolderCountTypeID = 0x601eb4c7

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeShareableChatFolderCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeShareableChatFolderCount{}
)

func (p *PremiumLimitTypeShareableChatFolderCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeShareableChatFolderCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeShareableChatFolderCount",
		ID:   PremiumLimitTypeShareableChatFolderCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeShareableChatFolderCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeShareableChatFolderCount#601eb4c7 as nil")
	}
	b.PutID(PremiumLimitTypeShareableChatFolderCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeShareableChatFolderCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeShareableChatFolderCount#601eb4c7 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeShareableChatFolderCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeShareableChatFolderCount#601eb4c7 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeShareableChatFolderCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeShareableChatFolderCount#601eb4c7: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeShareableChatFolderCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeShareableChatFolderCount#601eb4c7 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeShareableChatFolderCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeShareableChatFolderCount#601eb4c7 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeShareableChatFolderCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeShareableChatFolderCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeShareableChatFolderCount#601eb4c7 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeShareableChatFolderCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeShareableChatFolderCount#601eb4c7: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeActiveStoryCount represents TL type `premiumLimitTypeActiveStoryCount#8d2c269c`.
type PremiumLimitTypeActiveStoryCount struct {
}

// PremiumLimitTypeActiveStoryCountTypeID is TL type id of PremiumLimitTypeActiveStoryCount.
const PremiumLimitTypeActiveStoryCountTypeID = 0x8d2c269c

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeActiveStoryCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeActiveStoryCount{}
)

func (p *PremiumLimitTypeActiveStoryCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeActiveStoryCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeActiveStoryCount",
		ID:   PremiumLimitTypeActiveStoryCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeActiveStoryCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeActiveStoryCount#8d2c269c as nil")
	}
	b.PutID(PremiumLimitTypeActiveStoryCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeActiveStoryCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeActiveStoryCount#8d2c269c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeActiveStoryCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeActiveStoryCount#8d2c269c to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeActiveStoryCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeActiveStoryCount#8d2c269c: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeActiveStoryCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeActiveStoryCount#8d2c269c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeActiveStoryCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeActiveStoryCount#8d2c269c as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeActiveStoryCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeActiveStoryCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeActiveStoryCount#8d2c269c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeActiveStoryCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeActiveStoryCount#8d2c269c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeWeeklyPostedStoryCount represents TL type `premiumLimitTypeWeeklyPostedStoryCount#e1d1a577`.
type PremiumLimitTypeWeeklyPostedStoryCount struct {
}

// PremiumLimitTypeWeeklyPostedStoryCountTypeID is TL type id of PremiumLimitTypeWeeklyPostedStoryCount.
const PremiumLimitTypeWeeklyPostedStoryCountTypeID = 0xe1d1a577

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeWeeklyPostedStoryCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeWeeklyPostedStoryCount{}
)

func (p *PremiumLimitTypeWeeklyPostedStoryCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeWeeklyPostedStoryCount",
		ID:   PremiumLimitTypeWeeklyPostedStoryCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 as nil")
	}
	b.PutID(PremiumLimitTypeWeeklyPostedStoryCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeWeeklyPostedStoryCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeWeeklyPostedStoryCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeWeeklyPostedStoryCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeWeeklyPostedStoryCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeWeeklyPostedStoryCount#e1d1a577: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeMonthlyPostedStoryCount represents TL type `premiumLimitTypeMonthlyPostedStoryCount#191c192`.
type PremiumLimitTypeMonthlyPostedStoryCount struct {
}

// PremiumLimitTypeMonthlyPostedStoryCountTypeID is TL type id of PremiumLimitTypeMonthlyPostedStoryCount.
const PremiumLimitTypeMonthlyPostedStoryCountTypeID = 0x191c192

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeMonthlyPostedStoryCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeMonthlyPostedStoryCount{}
)

func (p *PremiumLimitTypeMonthlyPostedStoryCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeMonthlyPostedStoryCount",
		ID:   PremiumLimitTypeMonthlyPostedStoryCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeMonthlyPostedStoryCount#191c192 as nil")
	}
	b.PutID(PremiumLimitTypeMonthlyPostedStoryCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeMonthlyPostedStoryCount#191c192 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeMonthlyPostedStoryCount#191c192 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeMonthlyPostedStoryCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeMonthlyPostedStoryCount#191c192: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeMonthlyPostedStoryCount#191c192 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeMonthlyPostedStoryCount#191c192 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeMonthlyPostedStoryCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeMonthlyPostedStoryCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeMonthlyPostedStoryCount#191c192 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeMonthlyPostedStoryCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeMonthlyPostedStoryCount#191c192: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeStoryCaptionLength represents TL type `premiumLimitTypeStoryCaptionLength#bed53302`.
type PremiumLimitTypeStoryCaptionLength struct {
}

// PremiumLimitTypeStoryCaptionLengthTypeID is TL type id of PremiumLimitTypeStoryCaptionLength.
const PremiumLimitTypeStoryCaptionLengthTypeID = 0xbed53302

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeStoryCaptionLength) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeStoryCaptionLength{}
)

func (p *PremiumLimitTypeStoryCaptionLength) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeStoryCaptionLength) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeStoryCaptionLength",
		ID:   PremiumLimitTypeStoryCaptionLengthTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeStoryCaptionLength) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStoryCaptionLength#bed53302 as nil")
	}
	b.PutID(PremiumLimitTypeStoryCaptionLengthTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeStoryCaptionLength) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStoryCaptionLength#bed53302 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeStoryCaptionLength) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStoryCaptionLength#bed53302 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeStoryCaptionLengthTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeStoryCaptionLength#bed53302: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeStoryCaptionLength) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStoryCaptionLength#bed53302 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeStoryCaptionLength) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStoryCaptionLength#bed53302 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeStoryCaptionLength")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeStoryCaptionLength) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStoryCaptionLength#bed53302 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeStoryCaptionLength"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeStoryCaptionLength#bed53302: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeStorySuggestedReactionAreaCount represents TL type `premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807`.
type PremiumLimitTypeStorySuggestedReactionAreaCount struct {
}

// PremiumLimitTypeStorySuggestedReactionAreaCountTypeID is TL type id of PremiumLimitTypeStorySuggestedReactionAreaCount.
const PremiumLimitTypeStorySuggestedReactionAreaCountTypeID = 0xba42b807

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeStorySuggestedReactionAreaCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeStorySuggestedReactionAreaCount{}
)

func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeStorySuggestedReactionAreaCount",
		ID:   PremiumLimitTypeStorySuggestedReactionAreaCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 as nil")
	}
	b.PutID(PremiumLimitTypeStorySuggestedReactionAreaCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeStorySuggestedReactionAreaCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeStorySuggestedReactionAreaCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeStorySuggestedReactionAreaCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeStorySuggestedReactionAreaCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeSimilarChatCount represents TL type `premiumLimitTypeSimilarChatCount#a2ce1f11`.
type PremiumLimitTypeSimilarChatCount struct {
}

// PremiumLimitTypeSimilarChatCountTypeID is TL type id of PremiumLimitTypeSimilarChatCount.
const PremiumLimitTypeSimilarChatCountTypeID = 0xa2ce1f11

// construct implements constructor of PremiumLimitTypeClass.
func (p PremiumLimitTypeSimilarChatCount) construct() PremiumLimitTypeClass { return &p }

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

	_ PremiumLimitTypeClass = &PremiumLimitTypeSimilarChatCount{}
)

func (p *PremiumLimitTypeSimilarChatCount) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PremiumLimitTypeSimilarChatCount) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "premiumLimitTypeSimilarChatCount",
		ID:   PremiumLimitTypeSimilarChatCountTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PremiumLimitTypeSimilarChatCount) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSimilarChatCount#a2ce1f11 as nil")
	}
	b.PutID(PremiumLimitTypeSimilarChatCountTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PremiumLimitTypeSimilarChatCount) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSimilarChatCount#a2ce1f11 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PremiumLimitTypeSimilarChatCount) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSimilarChatCount#a2ce1f11 to nil")
	}
	if err := b.ConsumeID(PremiumLimitTypeSimilarChatCountTypeID); err != nil {
		return fmt.Errorf("unable to decode premiumLimitTypeSimilarChatCount#a2ce1f11: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PremiumLimitTypeSimilarChatCount) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSimilarChatCount#a2ce1f11 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PremiumLimitTypeSimilarChatCount) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode premiumLimitTypeSimilarChatCount#a2ce1f11 as nil")
	}
	b.ObjStart()
	b.PutID("premiumLimitTypeSimilarChatCount")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PremiumLimitTypeSimilarChatCount) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode premiumLimitTypeSimilarChatCount#a2ce1f11 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("premiumLimitTypeSimilarChatCount"); err != nil {
				return fmt.Errorf("unable to decode premiumLimitTypeSimilarChatCount#a2ce1f11: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PremiumLimitTypeClassName is schema name of PremiumLimitTypeClass.
const PremiumLimitTypeClassName = "PremiumLimitType"

// PremiumLimitTypeClass represents PremiumLimitType generic type.
//
// Example:
//
//	g, err := tdapi.DecodePremiumLimitType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.PremiumLimitTypeSupergroupCount: // premiumLimitTypeSupergroupCount#f13ff385
//	case *tdapi.PremiumLimitTypePinnedChatCount: // premiumLimitTypePinnedChatCount#c47543e1
//	case *tdapi.PremiumLimitTypeCreatedPublicChatCount: // premiumLimitTypeCreatedPublicChatCount#1a96beb9
//	case *tdapi.PremiumLimitTypeSavedAnimationCount: // premiumLimitTypeSavedAnimationCount#fed27d89
//	case *tdapi.PremiumLimitTypeFavoriteStickerCount: // premiumLimitTypeFavoriteStickerCount#2621e223
//	case *tdapi.PremiumLimitTypeChatFolderCount: // premiumLimitTypeChatFolderCount#1680096e
//	case *tdapi.PremiumLimitTypeChatFolderChosenChatCount: // premiumLimitTypeChatFolderChosenChatCount#64d14355
//	case *tdapi.PremiumLimitTypePinnedArchivedChatCount: // premiumLimitTypePinnedArchivedChatCount#588b2a0c
//	case *tdapi.PremiumLimitTypePinnedSavedMessagesTopicCount: // premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df
//	case *tdapi.PremiumLimitTypeCaptionLength: // premiumLimitTypeCaptionLength#1185d83a
//	case *tdapi.PremiumLimitTypeBioLength: // premiumLimitTypeBioLength#bba28603
//	case *tdapi.PremiumLimitTypeChatFolderInviteLinkCount: // premiumLimitTypeChatFolderInviteLinkCount#f854261a
//	case *tdapi.PremiumLimitTypeShareableChatFolderCount: // premiumLimitTypeShareableChatFolderCount#601eb4c7
//	case *tdapi.PremiumLimitTypeActiveStoryCount: // premiumLimitTypeActiveStoryCount#8d2c269c
//	case *tdapi.PremiumLimitTypeWeeklyPostedStoryCount: // premiumLimitTypeWeeklyPostedStoryCount#e1d1a577
//	case *tdapi.PremiumLimitTypeMonthlyPostedStoryCount: // premiumLimitTypeMonthlyPostedStoryCount#191c192
//	case *tdapi.PremiumLimitTypeStoryCaptionLength: // premiumLimitTypeStoryCaptionLength#bed53302
//	case *tdapi.PremiumLimitTypeStorySuggestedReactionAreaCount: // premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807
//	case *tdapi.PremiumLimitTypeSimilarChatCount: // premiumLimitTypeSimilarChatCount#a2ce1f11
//	default: panic(v)
//	}
type PremiumLimitTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PremiumLimitTypeClass

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

	EncodeTDLibJSON(b tdjson.Encoder) error
	DecodeTDLibJSON(b tdjson.Decoder) error
}

// DecodePremiumLimitType implements binary de-serialization for PremiumLimitTypeClass.
func DecodePremiumLimitType(buf *bin.Buffer) (PremiumLimitTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case PremiumLimitTypeSupergroupCountTypeID:
		// Decoding premiumLimitTypeSupergroupCount#f13ff385.
		v := PremiumLimitTypeSupergroupCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypePinnedChatCountTypeID:
		// Decoding premiumLimitTypePinnedChatCount#c47543e1.
		v := PremiumLimitTypePinnedChatCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeCreatedPublicChatCountTypeID:
		// Decoding premiumLimitTypeCreatedPublicChatCount#1a96beb9.
		v := PremiumLimitTypeCreatedPublicChatCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeSavedAnimationCountTypeID:
		// Decoding premiumLimitTypeSavedAnimationCount#fed27d89.
		v := PremiumLimitTypeSavedAnimationCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeFavoriteStickerCountTypeID:
		// Decoding premiumLimitTypeFavoriteStickerCount#2621e223.
		v := PremiumLimitTypeFavoriteStickerCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeChatFolderCountTypeID:
		// Decoding premiumLimitTypeChatFolderCount#1680096e.
		v := PremiumLimitTypeChatFolderCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeChatFolderChosenChatCountTypeID:
		// Decoding premiumLimitTypeChatFolderChosenChatCount#64d14355.
		v := PremiumLimitTypeChatFolderChosenChatCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypePinnedArchivedChatCountTypeID:
		// Decoding premiumLimitTypePinnedArchivedChatCount#588b2a0c.
		v := PremiumLimitTypePinnedArchivedChatCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypePinnedSavedMessagesTopicCountTypeID:
		// Decoding premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df.
		v := PremiumLimitTypePinnedSavedMessagesTopicCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeCaptionLengthTypeID:
		// Decoding premiumLimitTypeCaptionLength#1185d83a.
		v := PremiumLimitTypeCaptionLength{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeBioLengthTypeID:
		// Decoding premiumLimitTypeBioLength#bba28603.
		v := PremiumLimitTypeBioLength{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeChatFolderInviteLinkCountTypeID:
		// Decoding premiumLimitTypeChatFolderInviteLinkCount#f854261a.
		v := PremiumLimitTypeChatFolderInviteLinkCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeShareableChatFolderCountTypeID:
		// Decoding premiumLimitTypeShareableChatFolderCount#601eb4c7.
		v := PremiumLimitTypeShareableChatFolderCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeActiveStoryCountTypeID:
		// Decoding premiumLimitTypeActiveStoryCount#8d2c269c.
		v := PremiumLimitTypeActiveStoryCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeWeeklyPostedStoryCountTypeID:
		// Decoding premiumLimitTypeWeeklyPostedStoryCount#e1d1a577.
		v := PremiumLimitTypeWeeklyPostedStoryCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeMonthlyPostedStoryCountTypeID:
		// Decoding premiumLimitTypeMonthlyPostedStoryCount#191c192.
		v := PremiumLimitTypeMonthlyPostedStoryCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeStoryCaptionLengthTypeID:
		// Decoding premiumLimitTypeStoryCaptionLength#bed53302.
		v := PremiumLimitTypeStoryCaptionLength{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeStorySuggestedReactionAreaCountTypeID:
		// Decoding premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807.
		v := PremiumLimitTypeStorySuggestedReactionAreaCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case PremiumLimitTypeSimilarChatCountTypeID:
		// Decoding premiumLimitTypeSimilarChatCount#a2ce1f11.
		v := PremiumLimitTypeSimilarChatCount{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONPremiumLimitType implements binary de-serialization for PremiumLimitTypeClass.
func DecodeTDLibJSONPremiumLimitType(buf tdjson.Decoder) (PremiumLimitTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "premiumLimitTypeSupergroupCount":
		// Decoding premiumLimitTypeSupergroupCount#f13ff385.
		v := PremiumLimitTypeSupergroupCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypePinnedChatCount":
		// Decoding premiumLimitTypePinnedChatCount#c47543e1.
		v := PremiumLimitTypePinnedChatCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeCreatedPublicChatCount":
		// Decoding premiumLimitTypeCreatedPublicChatCount#1a96beb9.
		v := PremiumLimitTypeCreatedPublicChatCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeSavedAnimationCount":
		// Decoding premiumLimitTypeSavedAnimationCount#fed27d89.
		v := PremiumLimitTypeSavedAnimationCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeFavoriteStickerCount":
		// Decoding premiumLimitTypeFavoriteStickerCount#2621e223.
		v := PremiumLimitTypeFavoriteStickerCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeChatFolderCount":
		// Decoding premiumLimitTypeChatFolderCount#1680096e.
		v := PremiumLimitTypeChatFolderCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeChatFolderChosenChatCount":
		// Decoding premiumLimitTypeChatFolderChosenChatCount#64d14355.
		v := PremiumLimitTypeChatFolderChosenChatCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypePinnedArchivedChatCount":
		// Decoding premiumLimitTypePinnedArchivedChatCount#588b2a0c.
		v := PremiumLimitTypePinnedArchivedChatCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypePinnedSavedMessagesTopicCount":
		// Decoding premiumLimitTypePinnedSavedMessagesTopicCount#a3eb64df.
		v := PremiumLimitTypePinnedSavedMessagesTopicCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeCaptionLength":
		// Decoding premiumLimitTypeCaptionLength#1185d83a.
		v := PremiumLimitTypeCaptionLength{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeBioLength":
		// Decoding premiumLimitTypeBioLength#bba28603.
		v := PremiumLimitTypeBioLength{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeChatFolderInviteLinkCount":
		// Decoding premiumLimitTypeChatFolderInviteLinkCount#f854261a.
		v := PremiumLimitTypeChatFolderInviteLinkCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeShareableChatFolderCount":
		// Decoding premiumLimitTypeShareableChatFolderCount#601eb4c7.
		v := PremiumLimitTypeShareableChatFolderCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeActiveStoryCount":
		// Decoding premiumLimitTypeActiveStoryCount#8d2c269c.
		v := PremiumLimitTypeActiveStoryCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeWeeklyPostedStoryCount":
		// Decoding premiumLimitTypeWeeklyPostedStoryCount#e1d1a577.
		v := PremiumLimitTypeWeeklyPostedStoryCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeMonthlyPostedStoryCount":
		// Decoding premiumLimitTypeMonthlyPostedStoryCount#191c192.
		v := PremiumLimitTypeMonthlyPostedStoryCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeStoryCaptionLength":
		// Decoding premiumLimitTypeStoryCaptionLength#bed53302.
		v := PremiumLimitTypeStoryCaptionLength{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeStorySuggestedReactionAreaCount":
		// Decoding premiumLimitTypeStorySuggestedReactionAreaCount#ba42b807.
		v := PremiumLimitTypeStorySuggestedReactionAreaCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	case "premiumLimitTypeSimilarChatCount":
		// Decoding premiumLimitTypeSimilarChatCount#a2ce1f11.
		v := PremiumLimitTypeSimilarChatCount{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode PremiumLimitTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// PremiumLimitType boxes the PremiumLimitTypeClass providing a helper.
type PremiumLimitTypeBox struct {
	PremiumLimitType PremiumLimitTypeClass
}

// Decode implements bin.Decoder for PremiumLimitTypeBox.
func (b *PremiumLimitTypeBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode PremiumLimitTypeBox to nil")
	}
	v, err := DecodePremiumLimitType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.PremiumLimitType = v
	return nil
}

// Encode implements bin.Encode for PremiumLimitTypeBox.
func (b *PremiumLimitTypeBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.PremiumLimitType == nil {
		return fmt.Errorf("unable to encode PremiumLimitTypeClass as nil")
	}
	return b.PremiumLimitType.Encode(buf)
}

// DecodeTDLibJSON implements bin.Decoder for PremiumLimitTypeBox.
func (b *PremiumLimitTypeBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode PremiumLimitTypeBox to nil")
	}
	v, err := DecodeTDLibJSONPremiumLimitType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.PremiumLimitType = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for PremiumLimitTypeBox.
func (b *PremiumLimitTypeBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.PremiumLimitType == nil {
		return fmt.Errorf("unable to encode PremiumLimitTypeClass as nil")
	}
	return b.PremiumLimitType.EncodeTDLibJSON(buf)
}
