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

// PremiumBoostsList represents TL type `premium.boostsList#86f8613c`.
// List of boosts¹ that were applied to a peer by multiple users.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/premium.boostsList for reference.
type PremiumBoostsList struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Total number of results
	Count int
	// Boosts¹
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	Boosts []Boost
	// Offset that can be used for pagination¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	//
	// Use SetNextOffset and GetNextOffset helpers.
	NextOffset string
	// Mentioned users
	Users []UserClass
}

// PremiumBoostsListTypeID is TL type id of PremiumBoostsList.
const PremiumBoostsListTypeID = 0x86f8613c

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

func ( *PremiumBoostsList) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Boosts == nil) {
		return false
	}
	if !(.NextOffset == "") {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PremiumBoostsList from given interface.
func ( *PremiumBoostsList) ( interface {
	() ( int)
	() ( []Boost)
	() ( string,  bool)
	() ( []UserClass)
}) {
	.Count = .()
	.Boosts = .()
	if ,  := .();  {
		.NextOffset = 
	}

	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PremiumBoostsList) () tdp.Type {
	 := tdp.Type{
		Name: "premium.boostsList",
		ID:   PremiumBoostsListTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Boosts",
			SchemaName: "boosts",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PremiumBoostsList) () {
	if !(.NextOffset == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PremiumBoostsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.boostsList#86f8613c as nil")
	}
	.PutID(PremiumBoostsListTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumBoostsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.boostsList#86f8613c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field flags: %w", )
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Boosts))
	for ,  := range .Boosts {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field boosts element with index %d: %w", , )
		}
	}
	if .Flags.Has(0) {
		.PutString(.NextOffset)
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode premium.boostsList#86f8613c: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumBoostsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.boostsList#86f8613c to nil")
	}
	if  := .ConsumeID(PremiumBoostsListTypeID);  != nil {
		return fmt.Errorf("unable to decode premium.boostsList#86f8613c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumBoostsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.boostsList#86f8613c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field boosts: %w", )
		}

		if  > 0 {
			.Boosts = make([]Boost, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  Boost
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field boosts: %w", )
			}
			.Boosts = append(.Boosts, )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field next_offset: %w", )
		}
		.NextOffset = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsList#86f8613c: field users: %w", )
		}

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

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

// GetBoosts returns value of Boosts field.
func ( *PremiumBoostsList) () ( []Boost) {
	if  == nil {
		return
	}
	return .Boosts
}

// SetNextOffset sets value of NextOffset conditional field.
func ( *PremiumBoostsList) ( string) {
	.Flags.Set(0)
	.NextOffset = 
}

// GetNextOffset returns value of NextOffset conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsList) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NextOffset, true
}

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

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