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

// HelpCountriesListNotModified represents TL type `help.countriesListNotModified#93cc1f32`.
// The country list has not changed
//
// See https://core.telegram.org/constructor/help.countriesListNotModified for reference.
type HelpCountriesListNotModified struct {
}

// HelpCountriesListNotModifiedTypeID is TL type id of HelpCountriesListNotModified.
const HelpCountriesListNotModifiedTypeID = 0x93cc1f32

// construct implements constructor of HelpCountriesListClass.
func ( HelpCountriesListNotModified) () HelpCountriesListClass { return & }

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

	_ HelpCountriesListClass = &HelpCountriesListNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*HelpCountriesListNotModified) () string {
	return "help.countriesListNotModified"
}

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

// Encode implements bin.Encoder.
func ( *HelpCountriesListNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.countriesListNotModified#93cc1f32 as nil")
	}
	.PutID(HelpCountriesListNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpCountriesListNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.countriesListNotModified#93cc1f32 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpCountriesListNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.countriesListNotModified#93cc1f32 to nil")
	}
	if  := .ConsumeID(HelpCountriesListNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode help.countriesListNotModified#93cc1f32: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpCountriesListNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.countriesListNotModified#93cc1f32 to nil")
	}
	return nil
}

// HelpCountriesList represents TL type `help.countriesList#87d0759e`.
// Name, ISO code, localized name and phone codes/patterns of all available countries
//
// See https://core.telegram.org/constructor/help.countriesList for reference.
type HelpCountriesList struct {
	// Name, ISO code, localized name and phone codes/patterns of all available countries
	Countries []HelpCountry
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
}

// HelpCountriesListTypeID is TL type id of HelpCountriesList.
const HelpCountriesListTypeID = 0x87d0759e

// construct implements constructor of HelpCountriesListClass.
func ( HelpCountriesList) () HelpCountriesListClass { return & }

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

	_ HelpCountriesListClass = &HelpCountriesList{}
)

func ( *HelpCountriesList) () bool {
	if  == nil {
		return true
	}
	if !(.Countries == nil) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills HelpCountriesList from given interface.
func ( *HelpCountriesList) ( interface {
	() ( []HelpCountry)
	() ( int)
}) {
	.Countries = .()
	.Hash = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpCountriesList) () string {
	return "help.countriesList"
}

// TypeInfo returns info about TL type.
func ( *HelpCountriesList) () tdp.Type {
	 := tdp.Type{
		Name: "help.countriesList",
		ID:   HelpCountriesListTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Countries",
			SchemaName: "countries",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpCountriesList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.countriesList#87d0759e as nil")
	}
	.PutID(HelpCountriesListTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpCountriesList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.countriesList#87d0759e as nil")
	}
	.PutVectorHeader(len(.Countries))
	for ,  := range .Countries {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.countriesList#87d0759e: field countries element with index %d: %w", , )
		}
	}
	.PutInt(.Hash)
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpCountriesList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.countriesList#87d0759e to nil")
	}
	if  := .ConsumeID(HelpCountriesListTypeID);  != nil {
		return fmt.Errorf("unable to decode help.countriesList#87d0759e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpCountriesList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.countriesList#87d0759e to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.countriesList#87d0759e: field countries: %w", )
		}

		if  > 0 {
			.Countries = make([]HelpCountry, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  HelpCountry
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode help.countriesList#87d0759e: field countries: %w", )
			}
			.Countries = append(.Countries, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.countriesList#87d0759e: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// GetCountries returns value of Countries field.
func ( *HelpCountriesList) () ( []HelpCountry) {
	if  == nil {
		return
	}
	return .Countries
}

// GetHash returns value of Hash field.
func ( *HelpCountriesList) () ( int) {
	if  == nil {
		return
	}
	return .Hash
}

// HelpCountriesListClassName is schema name of HelpCountriesListClass.
const HelpCountriesListClassName = "help.CountriesList"

// HelpCountriesListClass represents help.CountriesList generic type.
//
// See https://core.telegram.org/type/help.CountriesList for reference.
//
// Example:
//
//	g, err := tg.DecodeHelpCountriesList(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.HelpCountriesListNotModified: // help.countriesListNotModified#93cc1f32
//	case *tg.HelpCountriesList: // help.countriesList#87d0759e
//	default: panic(v)
//	}
type HelpCountriesListClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() HelpCountriesListClass

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

	// AsModified tries to map HelpCountriesListClass to HelpCountriesList.
	AsModified() (*HelpCountriesList, bool)
}

// AsModified tries to map HelpCountriesListNotModified to HelpCountriesList.
func ( *HelpCountriesListNotModified) () (*HelpCountriesList, bool) {
	return nil, false
}

// AsModified tries to map HelpCountriesList to HelpCountriesList.
func ( *HelpCountriesList) () (*HelpCountriesList, bool) {
	return , true
}

// DecodeHelpCountriesList implements binary de-serialization for HelpCountriesListClass.
func ( *bin.Buffer) (HelpCountriesListClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case HelpCountriesListNotModifiedTypeID:
		// Decoding help.countriesListNotModified#93cc1f32.
		 := HelpCountriesListNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpCountriesListClass: %w", )
		}
		return &, nil
	case HelpCountriesListTypeID:
		// Decoding help.countriesList#87d0759e.
		 := HelpCountriesList{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpCountriesListClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode HelpCountriesListClass: %w", bin.NewUnexpectedID())
	}
}

// HelpCountriesList boxes the HelpCountriesListClass providing a helper.
type HelpCountriesListBox struct {
	CountriesList HelpCountriesListClass
}

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

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