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

// LangPackLanguage represents TL type `langPackLanguage#eeca5ce3`.
// Identifies a localization pack
//
// See https://core.telegram.org/constructor/langPackLanguage for reference.
type LangPackLanguage struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the language pack is official
	Official bool
	// Is this a localization pack for an RTL language
	Rtl bool
	// Is this a beta localization pack?
	Beta bool
	// Language name
	Name string
	// Language name in the language itself
	NativeName string
	// Language code (pack identifier)
	LangCode string
	// Identifier of a base language pack; may be empty. If a string is missed in the
	// language pack, then it should be fetched from base language pack. Unsupported in
	// custom language packs
	//
	// Use SetBaseLangCode and GetBaseLangCode helpers.
	BaseLangCode string
	// A language code to be used to apply plural forms. See https://www.unicode
	// org/cldr/charts/latest/supplemental/language_plural_rules.html¹ for more info
	//
	// Links:
	//  1) https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
	PluralCode string
	// Total number of non-deleted strings from the language pack
	StringsCount int
	// Total number of translated strings from the language pack
	TranslatedCount int
	// Link to language translation interface; empty for custom local language packs
	TranslationsURL string
}

// LangPackLanguageTypeID is TL type id of LangPackLanguage.
const LangPackLanguageTypeID = 0xeeca5ce3

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

func ( *LangPackLanguage) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Official == false) {
		return false
	}
	if !(.Rtl == false) {
		return false
	}
	if !(.Beta == false) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.NativeName == "") {
		return false
	}
	if !(.LangCode == "") {
		return false
	}
	if !(.BaseLangCode == "") {
		return false
	}
	if !(.PluralCode == "") {
		return false
	}
	if !(.StringsCount == 0) {
		return false
	}
	if !(.TranslatedCount == 0) {
		return false
	}
	if !(.TranslationsURL == "") {
		return false
	}

	return true
}

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

// FillFrom fills LangPackLanguage from given interface.
func ( *LangPackLanguage) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string)
	() ( string)
	() ( string)
	() ( string,  bool)
	() ( string)
	() ( int)
	() ( int)
	() ( string)
}) {
	.Official = .()
	.Rtl = .()
	.Beta = .()
	.Name = .()
	.NativeName = .()
	.LangCode = .()
	if ,  := .();  {
		.BaseLangCode = 
	}

	.PluralCode = .()
	.StringsCount = .()
	.TranslatedCount = .()
	.TranslationsURL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *LangPackLanguage) () tdp.Type {
	 := tdp.Type{
		Name: "langPackLanguage",
		ID:   LangPackLanguageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Official",
			SchemaName: "official",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Rtl",
			SchemaName: "rtl",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Beta",
			SchemaName: "beta",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "NativeName",
			SchemaName: "native_name",
		},
		{
			Name:       "LangCode",
			SchemaName: "lang_code",
		},
		{
			Name:       "BaseLangCode",
			SchemaName: "base_lang_code",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PluralCode",
			SchemaName: "plural_code",
		},
		{
			Name:       "StringsCount",
			SchemaName: "strings_count",
		},
		{
			Name:       "TranslatedCount",
			SchemaName: "translated_count",
		},
		{
			Name:       "TranslationsURL",
			SchemaName: "translations_url",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *LangPackLanguage) () {
	if !(.Official == false) {
		.Flags.Set(0)
	}
	if !(.Rtl == false) {
		.Flags.Set(2)
	}
	if !(.Beta == false) {
		.Flags.Set(3)
	}
	if !(.BaseLangCode == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *LangPackLanguage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode langPackLanguage#eeca5ce3 as nil")
	}
	.PutID(LangPackLanguageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *LangPackLanguage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode langPackLanguage#eeca5ce3 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode langPackLanguage#eeca5ce3: field flags: %w", )
	}
	.PutString(.Name)
	.PutString(.NativeName)
	.PutString(.LangCode)
	if .Flags.Has(1) {
		.PutString(.BaseLangCode)
	}
	.PutString(.PluralCode)
	.PutInt(.StringsCount)
	.PutInt(.TranslatedCount)
	.PutString(.TranslationsURL)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *LangPackLanguage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode langPackLanguage#eeca5ce3 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field flags: %w", )
		}
	}
	.Official = .Flags.Has(0)
	.Rtl = .Flags.Has(2)
	.Beta = .Flags.Has(3)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field name: %w", )
		}
		.Name = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field native_name: %w", )
		}
		.NativeName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field lang_code: %w", )
		}
		.LangCode = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field base_lang_code: %w", )
		}
		.BaseLangCode = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field plural_code: %w", )
		}
		.PluralCode = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field strings_count: %w", )
		}
		.StringsCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field translated_count: %w", )
		}
		.TranslatedCount = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode langPackLanguage#eeca5ce3: field translations_url: %w", )
		}
		.TranslationsURL = 
	}
	return nil
}

// SetOfficial sets value of Official conditional field.
func ( *LangPackLanguage) ( bool) {
	if  {
		.Flags.Set(0)
		.Official = true
	} else {
		.Flags.Unset(0)
		.Official = false
	}
}

// GetOfficial returns value of Official conditional field.
func ( *LangPackLanguage) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetRtl sets value of Rtl conditional field.
func ( *LangPackLanguage) ( bool) {
	if  {
		.Flags.Set(2)
		.Rtl = true
	} else {
		.Flags.Unset(2)
		.Rtl = false
	}
}

// GetRtl returns value of Rtl conditional field.
func ( *LangPackLanguage) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetBeta sets value of Beta conditional field.
func ( *LangPackLanguage) ( bool) {
	if  {
		.Flags.Set(3)
		.Beta = true
	} else {
		.Flags.Unset(3)
		.Beta = false
	}
}

// GetBeta returns value of Beta conditional field.
func ( *LangPackLanguage) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// GetName returns value of Name field.
func ( *LangPackLanguage) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetNativeName returns value of NativeName field.
func ( *LangPackLanguage) () ( string) {
	if  == nil {
		return
	}
	return .NativeName
}

// GetLangCode returns value of LangCode field.
func ( *LangPackLanguage) () ( string) {
	if  == nil {
		return
	}
	return .LangCode
}

// SetBaseLangCode sets value of BaseLangCode conditional field.
func ( *LangPackLanguage) ( string) {
	.Flags.Set(1)
	.BaseLangCode = 
}

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

// GetPluralCode returns value of PluralCode field.
func ( *LangPackLanguage) () ( string) {
	if  == nil {
		return
	}
	return .PluralCode
}

// GetStringsCount returns value of StringsCount field.
func ( *LangPackLanguage) () ( int) {
	if  == nil {
		return
	}
	return .StringsCount
}

// GetTranslatedCount returns value of TranslatedCount field.
func ( *LangPackLanguage) () ( int) {
	if  == nil {
		return
	}
	return .TranslatedCount
}

// GetTranslationsURL returns value of TranslationsURL field.
func ( *LangPackLanguage) () ( string) {
	if  == nil {
		return
	}
	return .TranslationsURL
}