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

// AuthPasswordRecovery represents TL type `auth.passwordRecovery#137948a5`.
// Recovery info of a 2FA password¹, only for accounts with a recovery email
// configured².
//
// Links:
//  1. https://core.telegram.org/api/srp
//  2. https://core.telegram.org/api/srp#email-verification
//
// See https://core.telegram.org/constructor/auth.passwordRecovery for reference.
type AuthPasswordRecovery struct {
	// The email to which the recovery code was sent must match this pattern¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/pattern
	EmailPattern string
}

// AuthPasswordRecoveryTypeID is TL type id of AuthPasswordRecovery.
const AuthPasswordRecoveryTypeID = 0x137948a5

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

func ( *AuthPasswordRecovery) () bool {
	if  == nil {
		return true
	}
	if !(.EmailPattern == "") {
		return false
	}

	return true
}

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

// FillFrom fills AuthPasswordRecovery from given interface.
func ( *AuthPasswordRecovery) ( interface {
	() ( string)
}) {
	.EmailPattern = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthPasswordRecovery) () string {
	return "auth.passwordRecovery"
}

// TypeInfo returns info about TL type.
func ( *AuthPasswordRecovery) () tdp.Type {
	 := tdp.Type{
		Name: "auth.passwordRecovery",
		ID:   AuthPasswordRecoveryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "EmailPattern",
			SchemaName: "email_pattern",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthPasswordRecovery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.passwordRecovery#137948a5 as nil")
	}
	.PutID(AuthPasswordRecoveryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthPasswordRecovery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.passwordRecovery#137948a5 as nil")
	}
	.PutString(.EmailPattern)
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthPasswordRecovery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.passwordRecovery#137948a5 to nil")
	}
	if  := .ConsumeID(AuthPasswordRecoveryTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.passwordRecovery#137948a5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthPasswordRecovery) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.passwordRecovery#137948a5 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.passwordRecovery#137948a5: field email_pattern: %w", )
		}
		.EmailPattern = 
	}
	return nil
}

// GetEmailPattern returns value of EmailPattern field.
func ( *AuthPasswordRecovery) () ( string) {
	if  == nil {
		return
	}
	return .EmailPattern
}