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

// StarGiftAttributeCounter represents TL type `starGiftAttributeCounter#2eb1b658`.
// Indicates the total number of gifts that have the specified attribute.
//
// See https://core.telegram.org/constructor/starGiftAttributeCounter for reference.
type StarGiftAttributeCounter struct {
	// The attribute (just the ID, without the attribute itself).
	Attribute StarGiftAttributeIDClass
	// Total number of gifts with this attribute.
	Count int
}

// StarGiftAttributeCounterTypeID is TL type id of StarGiftAttributeCounter.
const StarGiftAttributeCounterTypeID = 0x2eb1b658

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeCounter) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeCounter",
		ID:   StarGiftAttributeCounterTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Attribute",
			SchemaName: "attribute",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeCounter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeCounter#2eb1b658 as nil")
	}
	.PutID(StarGiftAttributeCounterTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeCounter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeCounter#2eb1b658 as nil")
	}
	if .Attribute == nil {
		return fmt.Errorf("unable to encode starGiftAttributeCounter#2eb1b658: field attribute is nil")
	}
	if  := .Attribute.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeCounter#2eb1b658: field attribute: %w", )
	}
	.PutInt(.Count)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeCounter) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeCounter#2eb1b658 to nil")
	}
	{
		,  := DecodeStarGiftAttributeID()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeCounter#2eb1b658: field attribute: %w", )
		}
		.Attribute = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeCounter#2eb1b658: field count: %w", )
		}
		.Count = 
	}
	return nil
}

// GetAttribute returns value of Attribute field.
func ( *StarGiftAttributeCounter) () ( StarGiftAttributeIDClass) {
	if  == nil {
		return
	}
	return .Attribute
}

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