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

// NearestDC represents TL type `nearestDc#8e1a1775`.
// Nearest data center, according to geo-ip.
//
// See https://core.telegram.org/constructor/nearestDc for reference.
type NearestDC struct {
	// Country code determined by geo-ip
	Country string
	// Number of current data center
	ThisDC int
	// Number of nearest data center
	NearestDC int
}

// NearestDCTypeID is TL type id of NearestDC.
const NearestDCTypeID = 0x8e1a1775

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

func ( *NearestDC) () bool {
	if  == nil {
		return true
	}
	if !(.Country == "") {
		return false
	}
	if !(.ThisDC == 0) {
		return false
	}
	if !(.NearestDC == 0) {
		return false
	}

	return true
}

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

// FillFrom fills NearestDC from given interface.
func ( *NearestDC) ( interface {
	() ( string)
	() ( int)
	() ( int)
}) {
	.Country = .()
	.ThisDC = .()
	.NearestDC = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *NearestDC) () tdp.Type {
	 := tdp.Type{
		Name: "nearestDc",
		ID:   NearestDCTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Country",
			SchemaName: "country",
		},
		{
			Name:       "ThisDC",
			SchemaName: "this_dc",
		},
		{
			Name:       "NearestDC",
			SchemaName: "nearest_dc",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *NearestDC) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode nearestDc#8e1a1775 as nil")
	}
	.PutID(NearestDCTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *NearestDC) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode nearestDc#8e1a1775 as nil")
	}
	.PutString(.Country)
	.PutInt(.ThisDC)
	.PutInt(.NearestDC)
	return nil
}

// Decode implements bin.Decoder.
func ( *NearestDC) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode nearestDc#8e1a1775 to nil")
	}
	if  := .ConsumeID(NearestDCTypeID);  != nil {
		return fmt.Errorf("unable to decode nearestDc#8e1a1775: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *NearestDC) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode nearestDc#8e1a1775 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode nearestDc#8e1a1775: field country: %w", )
		}
		.Country = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode nearestDc#8e1a1775: field this_dc: %w", )
		}
		.ThisDC = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode nearestDc#8e1a1775: field nearest_dc: %w", )
		}
		.NearestDC = 
	}
	return nil
}

// GetCountry returns value of Country field.
func ( *NearestDC) () ( string) {
	if  == nil {
		return
	}
	return .Country
}

// GetThisDC returns value of ThisDC field.
func ( *NearestDC) () ( int) {
	if  == nil {
		return
	}
	return .ThisDC
}

// GetNearestDC returns value of NearestDC field.
func ( *NearestDC) () ( int) {
	if  == nil {
		return
	}
	return .NearestDC
}