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

// PremiumMyBoosts represents TL type `premium.myBoosts#9ae228e2`.
// A list of peers we are currently boosting¹, and how many boost slots² we have left.
//
// Links:
//  1. https://core.telegram.org/api/boost
//  2. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/premium.myBoosts for reference.
type PremiumMyBoosts struct {
	// Info about boosted peers and remaining boost slots.
	MyBoosts []MyBoost
	// Referenced chats
	Chats []ChatClass
	// Referenced users
	Users []UserClass
}

// PremiumMyBoostsTypeID is TL type id of PremiumMyBoosts.
const PremiumMyBoostsTypeID = 0x9ae228e2

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

func ( *PremiumMyBoosts) () bool {
	if  == nil {
		return true
	}
	if !(.MyBoosts == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PremiumMyBoosts from given interface.
func ( *PremiumMyBoosts) ( interface {
	() ( []MyBoost)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.MyBoosts = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*PremiumMyBoosts) () string {
	return "premium.myBoosts"
}

// TypeInfo returns info about TL type.
func ( *PremiumMyBoosts) () tdp.Type {
	 := tdp.Type{
		Name: "premium.myBoosts",
		ID:   PremiumMyBoostsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MyBoosts",
			SchemaName: "my_boosts",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PremiumMyBoosts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.myBoosts#9ae228e2 as nil")
	}
	.PutID(PremiumMyBoostsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumMyBoosts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.myBoosts#9ae228e2 as nil")
	}
	.PutVectorHeader(len(.MyBoosts))
	for ,  := range .MyBoosts {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field my_boosts element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode premium.myBoosts#9ae228e2: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumMyBoosts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.myBoosts#9ae228e2 to nil")
	}
	if  := .ConsumeID(PremiumMyBoostsTypeID);  != nil {
		return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumMyBoosts) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.myBoosts#9ae228e2 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field my_boosts: %w", )
		}

		if  > 0 {
			.MyBoosts = make([]MyBoost, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  MyBoost
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field my_boosts: %w", )
			}
			.MyBoosts = append(.MyBoosts, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode premium.myBoosts#9ae228e2: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetMyBoosts returns value of MyBoosts field.
func ( *PremiumMyBoosts) () ( []MyBoost) {
	if  == nil {
		return
	}
	return .MyBoosts
}

// GetChats returns value of Chats field.
func ( *PremiumMyBoosts) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *PremiumMyBoosts) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *PremiumMyBoosts) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *PremiumMyBoosts) () ( UserClassArray) {
	return UserClassArray(.Users)
}