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

// GeoPointAddress represents TL type `geoPointAddress#de4c5d93`.
// Address optionally associated to a geoPoint¹.
//
// Links:
//  1. https://core.telegram.org/constructor/geoPoint
//
// See https://core.telegram.org/constructor/geoPointAddress for reference.
type GeoPointAddress struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Two-letter ISO 3166-1 alpha-2 country code
	CountryISO2 string
	// State
	//
	// Use SetState and GetState helpers.
	State string
	// City
	//
	// Use SetCity and GetCity helpers.
	City string
	// Street
	//
	// Use SetStreet and GetStreet helpers.
	Street string
}

// GeoPointAddressTypeID is TL type id of GeoPointAddress.
const GeoPointAddressTypeID = 0xde4c5d93

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

func ( *GeoPointAddress) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.CountryISO2 == "") {
		return false
	}
	if !(.State == "") {
		return false
	}
	if !(.City == "") {
		return false
	}
	if !(.Street == "") {
		return false
	}

	return true
}

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

// FillFrom fills GeoPointAddress from given interface.
func ( *GeoPointAddress) ( interface {
	() ( string)
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
}) {
	.CountryISO2 = .()
	if ,  := .();  {
		.State = 
	}

	if ,  := .();  {
		.City = 
	}

	if ,  := .();  {
		.Street = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *GeoPointAddress) () tdp.Type {
	 := tdp.Type{
		Name: "geoPointAddress",
		ID:   GeoPointAddressTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CountryISO2",
			SchemaName: "country_iso2",
		},
		{
			Name:       "State",
			SchemaName: "state",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "City",
			SchemaName: "city",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Street",
			SchemaName: "street",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *GeoPointAddress) () {
	if !(.State == "") {
		.Flags.Set(0)
	}
	if !(.City == "") {
		.Flags.Set(1)
	}
	if !(.Street == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *GeoPointAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode geoPointAddress#de4c5d93 as nil")
	}
	.PutID(GeoPointAddressTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *GeoPointAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode geoPointAddress#de4c5d93 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode geoPointAddress#de4c5d93: field flags: %w", )
	}
	.PutString(.CountryISO2)
	if .Flags.Has(0) {
		.PutString(.State)
	}
	if .Flags.Has(1) {
		.PutString(.City)
	}
	if .Flags.Has(2) {
		.PutString(.Street)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *GeoPointAddress) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode geoPointAddress#de4c5d93 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode geoPointAddress#de4c5d93: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode geoPointAddress#de4c5d93: field country_iso2: %w", )
		}
		.CountryISO2 = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode geoPointAddress#de4c5d93: field state: %w", )
		}
		.State = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode geoPointAddress#de4c5d93: field city: %w", )
		}
		.City = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode geoPointAddress#de4c5d93: field street: %w", )
		}
		.Street = 
	}
	return nil
}

// GetCountryISO2 returns value of CountryISO2 field.
func ( *GeoPointAddress) () ( string) {
	if  == nil {
		return
	}
	return .CountryISO2
}

// SetState sets value of State conditional field.
func ( *GeoPointAddress) ( string) {
	.Flags.Set(0)
	.State = 
}

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

// SetCity sets value of City conditional field.
func ( *GeoPointAddress) ( string) {
	.Flags.Set(1)
	.City = 
}

// GetCity returns value of City conditional field and
// boolean which is true if field was set.
func ( *GeoPointAddress) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .City, true
}

// SetStreet sets value of Street conditional field.
func ( *GeoPointAddress) ( string) {
	.Flags.Set(2)
	.Street = 
}

// GetStreet returns value of Street conditional field and
// boolean which is true if field was set.
func ( *GeoPointAddress) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Street, true
}