// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// StarGiftAttributeRarity represents TL type `starGiftAttributeRarity#36437737`.
// Exact rarity value for a collectible gift attribute.
//
// See https://core.telegram.org/constructor/starGiftAttributeRarity for reference.
type StarGiftAttributeRarity struct {
	// Probability of this attribute, in permille
	Permille int
}

// StarGiftAttributeRarityTypeID is TL type id of StarGiftAttributeRarity.
const StarGiftAttributeRarityTypeID = 0x36437737

// construct implements constructor of StarGiftAttributeRarityClass.
func ( StarGiftAttributeRarity) () StarGiftAttributeRarityClass { return & }

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

	_ StarGiftAttributeRarityClass = &StarGiftAttributeRarity{}
)

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

	return true
}

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

// FillFrom fills StarGiftAttributeRarity from given interface.
func ( *StarGiftAttributeRarity) ( interface {
	() ( int)
}) {
	.Permille = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeRarity) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeRarity",
		ID:   StarGiftAttributeRarityTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Permille",
			SchemaName: "permille",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeRarity) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarity#36437737 as nil")
	}
	.PutID(StarGiftAttributeRarityTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeRarity) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarity#36437737 as nil")
	}
	.PutInt(.Permille)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeRarity) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeRarity#36437737 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeRarity#36437737: field permille: %w", )
		}
		.Permille = 
	}
	return nil
}

// GetPermille returns value of Permille field.
func ( *StarGiftAttributeRarity) () ( int) {
	if  == nil {
		return
	}
	return .Permille
}

// StarGiftAttributeRarityUncommon represents TL type `starGiftAttributeRarityUncommon#dbce6389`.
// Represents uncommon collectible gift attribute rarity.
//
// See https://core.telegram.org/constructor/starGiftAttributeRarityUncommon for reference.
type StarGiftAttributeRarityUncommon struct {
}

// StarGiftAttributeRarityUncommonTypeID is TL type id of StarGiftAttributeRarityUncommon.
const StarGiftAttributeRarityUncommonTypeID = 0xdbce6389

// construct implements constructor of StarGiftAttributeRarityClass.
func ( StarGiftAttributeRarityUncommon) () StarGiftAttributeRarityClass { return & }

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

	_ StarGiftAttributeRarityClass = &StarGiftAttributeRarityUncommon{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *StarGiftAttributeRarityUncommon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityUncommon#dbce6389 as nil")
	}
	.PutID(StarGiftAttributeRarityUncommonTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeRarityUncommon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityUncommon#dbce6389 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeRarityUncommon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeRarityUncommon#dbce6389 to nil")
	}
	return nil
}

// StarGiftAttributeRarityRare represents TL type `starGiftAttributeRarityRare#f08d516b`.
// Represents rare collectible gift attribute rarity.
//
// See https://core.telegram.org/constructor/starGiftAttributeRarityRare for reference.
type StarGiftAttributeRarityRare struct {
}

// StarGiftAttributeRarityRareTypeID is TL type id of StarGiftAttributeRarityRare.
const StarGiftAttributeRarityRareTypeID = 0xf08d516b

// construct implements constructor of StarGiftAttributeRarityClass.
func ( StarGiftAttributeRarityRare) () StarGiftAttributeRarityClass { return & }

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

	_ StarGiftAttributeRarityClass = &StarGiftAttributeRarityRare{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *StarGiftAttributeRarityRare) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityRare#f08d516b as nil")
	}
	.PutID(StarGiftAttributeRarityRareTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeRarityRare) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityRare#f08d516b as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeRarityRare) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeRarityRare#f08d516b to nil")
	}
	return nil
}

// StarGiftAttributeRarityEpic represents TL type `starGiftAttributeRarityEpic#78fbf3a8`.
// Represents epic collectible gift attribute rarity.
//
// See https://core.telegram.org/constructor/starGiftAttributeRarityEpic for reference.
type StarGiftAttributeRarityEpic struct {
}

// StarGiftAttributeRarityEpicTypeID is TL type id of StarGiftAttributeRarityEpic.
const StarGiftAttributeRarityEpicTypeID = 0x78fbf3a8

// construct implements constructor of StarGiftAttributeRarityClass.
func ( StarGiftAttributeRarityEpic) () StarGiftAttributeRarityClass { return & }

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

	_ StarGiftAttributeRarityClass = &StarGiftAttributeRarityEpic{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *StarGiftAttributeRarityEpic) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityEpic#78fbf3a8 as nil")
	}
	.PutID(StarGiftAttributeRarityEpicTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeRarityEpic) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityEpic#78fbf3a8 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeRarityEpic) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeRarityEpic#78fbf3a8 to nil")
	}
	return nil
}

// StarGiftAttributeRarityLegendary represents TL type `starGiftAttributeRarityLegendary#cef7e7a8`.
// Represents legendary collectible gift attribute rarity.
//
// See https://core.telegram.org/constructor/starGiftAttributeRarityLegendary for reference.
type StarGiftAttributeRarityLegendary struct {
}

// StarGiftAttributeRarityLegendaryTypeID is TL type id of StarGiftAttributeRarityLegendary.
const StarGiftAttributeRarityLegendaryTypeID = 0xcef7e7a8

// construct implements constructor of StarGiftAttributeRarityClass.
func ( StarGiftAttributeRarityLegendary) () StarGiftAttributeRarityClass { return & }

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

	_ StarGiftAttributeRarityClass = &StarGiftAttributeRarityLegendary{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *StarGiftAttributeRarityLegendary) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityLegendary#cef7e7a8 as nil")
	}
	.PutID(StarGiftAttributeRarityLegendaryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeRarityLegendary) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeRarityLegendary#cef7e7a8 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeRarityLegendary) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeRarityLegendary#cef7e7a8 to nil")
	}
	return nil
}

// StarGiftAttributeRarityClassName is schema name of StarGiftAttributeRarityClass.
const StarGiftAttributeRarityClassName = "StarGiftAttributeRarity"

// StarGiftAttributeRarityClass represents StarGiftAttributeRarity generic type.
//
// See https://core.telegram.org/type/StarGiftAttributeRarity for reference.
//
// Constructors:
//   - [StarGiftAttributeRarity]
//   - [StarGiftAttributeRarityUncommon]
//   - [StarGiftAttributeRarityRare]
//   - [StarGiftAttributeRarityEpic]
//   - [StarGiftAttributeRarityLegendary]
//
// Example:
//
//	g, err := tg.DecodeStarGiftAttributeRarity(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StarGiftAttributeRarity: // starGiftAttributeRarity#36437737
//	case *tg.StarGiftAttributeRarityUncommon: // starGiftAttributeRarityUncommon#dbce6389
//	case *tg.StarGiftAttributeRarityRare: // starGiftAttributeRarityRare#f08d516b
//	case *tg.StarGiftAttributeRarityEpic: // starGiftAttributeRarityEpic#78fbf3a8
//	case *tg.StarGiftAttributeRarityLegendary: // starGiftAttributeRarityLegendary#cef7e7a8
//	default: panic(v)
//	}
type StarGiftAttributeRarityClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarGiftAttributeRarityClass

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

// DecodeStarGiftAttributeRarity implements binary de-serialization for StarGiftAttributeRarityClass.
func ( *bin.Buffer) (StarGiftAttributeRarityClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StarGiftAttributeRarityTypeID:
		// Decoding starGiftAttributeRarity#36437737.
		 := StarGiftAttributeRarity{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", )
		}
		return &, nil
	case StarGiftAttributeRarityUncommonTypeID:
		// Decoding starGiftAttributeRarityUncommon#dbce6389.
		 := StarGiftAttributeRarityUncommon{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", )
		}
		return &, nil
	case StarGiftAttributeRarityRareTypeID:
		// Decoding starGiftAttributeRarityRare#f08d516b.
		 := StarGiftAttributeRarityRare{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", )
		}
		return &, nil
	case StarGiftAttributeRarityEpicTypeID:
		// Decoding starGiftAttributeRarityEpic#78fbf3a8.
		 := StarGiftAttributeRarityEpic{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", )
		}
		return &, nil
	case StarGiftAttributeRarityLegendaryTypeID:
		// Decoding starGiftAttributeRarityLegendary#cef7e7a8.
		 := StarGiftAttributeRarityLegendary{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StarGiftAttributeRarityClass: %w", bin.NewUnexpectedID())
	}
}

// StarGiftAttributeRarity boxes the StarGiftAttributeRarityClass providing a helper.
type StarGiftAttributeRarityBox struct {
	StarGiftAttributeRarity StarGiftAttributeRarityClass
}

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

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