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

// SecurePlainPhone represents TL type `securePlainPhone#7d6099dd`.
// Phone number to use in telegram passport¹: it must be verified, first »².
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#secureplaindata
//
// See https://core.telegram.org/constructor/securePlainPhone for reference.
type SecurePlainPhone struct {
	// Phone number
	Phone string
}

// SecurePlainPhoneTypeID is TL type id of SecurePlainPhone.
const SecurePlainPhoneTypeID = 0x7d6099dd

// construct implements constructor of SecurePlainDataClass.
func ( SecurePlainPhone) () SecurePlainDataClass { return & }

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

	_ SecurePlainDataClass = &SecurePlainPhone{}
)

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

	return true
}

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

// FillFrom fills SecurePlainPhone from given interface.
func ( *SecurePlainPhone) ( interface {
	() ( string)
}) {
	.Phone = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecurePlainPhone) () tdp.Type {
	 := tdp.Type{
		Name: "securePlainPhone",
		ID:   SecurePlainPhoneTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Phone",
			SchemaName: "phone",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecurePlainPhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePlainPhone#7d6099dd as nil")
	}
	.PutID(SecurePlainPhoneTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecurePlainPhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePlainPhone#7d6099dd as nil")
	}
	.PutString(.Phone)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecurePlainPhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode securePlainPhone#7d6099dd to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode securePlainPhone#7d6099dd: field phone: %w", )
		}
		.Phone = 
	}
	return nil
}

// GetPhone returns value of Phone field.
func ( *SecurePlainPhone) () ( string) {
	if  == nil {
		return
	}
	return .Phone
}

// SecurePlainEmail represents TL type `securePlainEmail#21ec5a5f`.
// Email address to use in telegram passport¹: it must be verified, first »².
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#secureplaindata
//
// See https://core.telegram.org/constructor/securePlainEmail for reference.
type SecurePlainEmail struct {
	// Email address
	Email string
}

// SecurePlainEmailTypeID is TL type id of SecurePlainEmail.
const SecurePlainEmailTypeID = 0x21ec5a5f

// construct implements constructor of SecurePlainDataClass.
func ( SecurePlainEmail) () SecurePlainDataClass { return & }

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

	_ SecurePlainDataClass = &SecurePlainEmail{}
)

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

	return true
}

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

// FillFrom fills SecurePlainEmail from given interface.
func ( *SecurePlainEmail) ( interface {
	() ( string)
}) {
	.Email = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SecurePlainEmail) () tdp.Type {
	 := tdp.Type{
		Name: "securePlainEmail",
		ID:   SecurePlainEmailTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Email",
			SchemaName: "email",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SecurePlainEmail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePlainEmail#21ec5a5f as nil")
	}
	.PutID(SecurePlainEmailTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SecurePlainEmail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode securePlainEmail#21ec5a5f as nil")
	}
	.PutString(.Email)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SecurePlainEmail) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode securePlainEmail#21ec5a5f to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode securePlainEmail#21ec5a5f: field email: %w", )
		}
		.Email = 
	}
	return nil
}

// GetEmail returns value of Email field.
func ( *SecurePlainEmail) () ( string) {
	if  == nil {
		return
	}
	return .Email
}

// SecurePlainDataClassName is schema name of SecurePlainDataClass.
const SecurePlainDataClassName = "SecurePlainData"

// SecurePlainDataClass represents SecurePlainData generic type.
//
// See https://core.telegram.org/type/SecurePlainData for reference.
//
// Example:
//
//	g, err := tg.DecodeSecurePlainData(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.SecurePlainPhone: // securePlainPhone#7d6099dd
//	case *tg.SecurePlainEmail: // securePlainEmail#21ec5a5f
//	default: panic(v)
//	}
type SecurePlainDataClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() SecurePlainDataClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeSecurePlainData implements binary de-serialization for SecurePlainDataClass.
func ( *bin.Buffer) (SecurePlainDataClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case SecurePlainPhoneTypeID:
		// Decoding securePlainPhone#7d6099dd.
		 := SecurePlainPhone{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecurePlainDataClass: %w", )
		}
		return &, nil
	case SecurePlainEmailTypeID:
		// Decoding securePlainEmail#21ec5a5f.
		 := SecurePlainEmail{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode SecurePlainDataClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode SecurePlainDataClass: %w", bin.NewUnexpectedID())
	}
}

// SecurePlainData boxes the SecurePlainDataClass providing a helper.
type SecurePlainDataBox struct {
	SecurePlainData SecurePlainDataClass
}

// Decode implements bin.Decoder for SecurePlainDataBox.
func ( *SecurePlainDataBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode SecurePlainDataBox to nil")
	}
	,  := DecodeSecurePlainData()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.SecurePlainData = 
	return nil
}

// Encode implements bin.Encode for SecurePlainDataBox.
func ( *SecurePlainDataBox) ( *bin.Buffer) error {
	if  == nil || .SecurePlainData == nil {
		return fmt.Errorf("unable to encode SecurePlainDataClass as nil")
	}
	return .SecurePlainData.Encode()
}