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

// AccountPasswordSettings represents TL type `account.passwordSettings#9a5c33e5`.
// Private info associated to the password info (recovery email, telegram passport¹ info
// & so on)
//
// Links:
//  1. https://core.telegram.org/passport
//
// See https://core.telegram.org/constructor/account.passwordSettings for reference.
type AccountPasswordSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// 2FA Recovery email¹
	//
	// Links:
	//  1) https://core.telegram.org/api/srp#email-verification
	//
	// Use SetEmail and GetEmail helpers.
	Email string
	// Telegram passport¹ settings
	//
	// Links:
	//  1) https://core.telegram.org/passport
	//
	// Use SetSecureSettings and GetSecureSettings helpers.
	SecureSettings SecureSecretSettings
}

// AccountPasswordSettingsTypeID is TL type id of AccountPasswordSettings.
const AccountPasswordSettingsTypeID = 0x9a5c33e5

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

func ( *AccountPasswordSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Email == "") {
		return false
	}
	if !(.SecureSettings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountPasswordSettings from given interface.
func ( *AccountPasswordSettings) ( interface {
	() ( string,  bool)
	() ( SecureSecretSettings,  bool)
}) {
	if ,  := .();  {
		.Email = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*AccountPasswordSettings) () string {
	return "account.passwordSettings"
}

// TypeInfo returns info about TL type.
func ( *AccountPasswordSettings) () tdp.Type {
	 := tdp.Type{
		Name: "account.passwordSettings",
		ID:   AccountPasswordSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Email",
			SchemaName: "email",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SecureSettings",
			SchemaName: "secure_settings",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountPasswordSettings) () {
	if !(.Email == "") {
		.Flags.Set(0)
	}
	if !(.SecureSettings.Zero()) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AccountPasswordSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.passwordSettings#9a5c33e5 as nil")
	}
	.PutID(AccountPasswordSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountPasswordSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.passwordSettings#9a5c33e5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.passwordSettings#9a5c33e5: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Email)
	}
	if .Flags.Has(1) {
		if  := .SecureSettings.Encode();  != nil {
			return fmt.Errorf("unable to encode account.passwordSettings#9a5c33e5: field secure_settings: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountPasswordSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.passwordSettings#9a5c33e5 to nil")
	}
	if  := .ConsumeID(AccountPasswordSettingsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.passwordSettings#9a5c33e5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountPasswordSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.passwordSettings#9a5c33e5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.passwordSettings#9a5c33e5: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.passwordSettings#9a5c33e5: field email: %w", )
		}
		.Email = 
	}
	if .Flags.Has(1) {
		if  := .SecureSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.passwordSettings#9a5c33e5: field secure_settings: %w", )
		}
	}
	return nil
}

// SetEmail sets value of Email conditional field.
func ( *AccountPasswordSettings) ( string) {
	.Flags.Set(0)
	.Email = 
}

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

// SetSecureSettings sets value of SecureSettings conditional field.
func ( *AccountPasswordSettings) ( SecureSecretSettings) {
	.Flags.Set(1)
	.SecureSettings = 
}

// GetSecureSettings returns value of SecureSettings conditional field and
// boolean which is true if field was set.
func ( *AccountPasswordSettings) () ( SecureSecretSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .SecureSettings, true
}