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

// AccountSentEmailCode represents TL type `account.sentEmailCode#811f854f`.
// The sent email code
//
// See https://core.telegram.org/constructor/account.sentEmailCode for reference.
type AccountSentEmailCode struct {
	// The email (to which the code was sent) must match this patternĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/pattern
	EmailPattern string
	// The length of the verification code
	Length int
}

// AccountSentEmailCodeTypeID is TL type id of AccountSentEmailCode.
const AccountSentEmailCodeTypeID = 0x811f854f

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *AccountSentEmailCode) () tdp.Type {
	 := tdp.Type{
		Name: "account.sentEmailCode",
		ID:   AccountSentEmailCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "EmailPattern",
			SchemaName: "email_pattern",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSentEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sentEmailCode#811f854f as nil")
	}
	.PutID(AccountSentEmailCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSentEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.sentEmailCode#811f854f as nil")
	}
	.PutString(.EmailPattern)
	.PutInt(.Length)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountSentEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.sentEmailCode#811f854f to nil")
	}
	if  := .ConsumeID(AccountSentEmailCodeTypeID);  != nil {
		return fmt.Errorf("unable to decode account.sentEmailCode#811f854f: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountSentEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.sentEmailCode#811f854f to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.sentEmailCode#811f854f: field email_pattern: %w", )
		}
		.EmailPattern = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.sentEmailCode#811f854f: field length: %w", )
		}
		.Length = 
	}
	return nil
}

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

// GetLength returns value of Length field.
func ( *AccountSentEmailCode) () ( int) {
	if  == nil {
		return
	}
	return .Length
}