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

// MessagesHighScores represents TL type `messages.highScores#9a3bfd99`.
// Highscores in a game
//
// See https://core.telegram.org/constructor/messages.highScores for reference.
type MessagesHighScores struct {
	// Highscores
	Scores []HighScore
	// Users, associated to the highscores
	Users []UserClass
}

// MessagesHighScoresTypeID is TL type id of MessagesHighScores.
const MessagesHighScoresTypeID = 0x9a3bfd99

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

func ( *MessagesHighScores) () bool {
	if  == nil {
		return true
	}
	if !(.Scores == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesHighScores from given interface.
func ( *MessagesHighScores) ( interface {
	() ( []HighScore)
	() ( []UserClass)
}) {
	.Scores = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesHighScores) () string {
	return "messages.highScores"
}

// TypeInfo returns info about TL type.
func ( *MessagesHighScores) () tdp.Type {
	 := tdp.Type{
		Name: "messages.highScores",
		ID:   MessagesHighScoresTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Scores",
			SchemaName: "scores",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesHighScores) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.highScores#9a3bfd99 as nil")
	}
	.PutID(MessagesHighScoresTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesHighScores) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.highScores#9a3bfd99 as nil")
	}
	.PutVectorHeader(len(.Scores))
	for ,  := range .Scores {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.highScores#9a3bfd99: field scores element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.highScores#9a3bfd99: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.highScores#9a3bfd99: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesHighScores) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.highScores#9a3bfd99 to nil")
	}
	if  := .ConsumeID(MessagesHighScoresTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.highScores#9a3bfd99: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesHighScores) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.highScores#9a3bfd99 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.highScores#9a3bfd99: field scores: %w", )
		}

		if  > 0 {
			.Scores = make([]HighScore, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  HighScore
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.highScores#9a3bfd99: field scores: %w", )
			}
			.Scores = append(.Scores, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.highScores#9a3bfd99: field users: %w", )
		}

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

// GetScores returns value of Scores field.
func ( *MessagesHighScores) () ( []HighScore) {
	if  == nil {
		return
	}
	return .Scores
}

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

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