// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// PassportElementTypePersonalDetails represents TL type `passportElementTypePersonalDetails#c27ad953`.
type PassportElementTypePersonalDetails struct {
}

// PassportElementTypePersonalDetailsTypeID is TL type id of PassportElementTypePersonalDetails.
const PassportElementTypePersonalDetailsTypeID = 0xc27ad953

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypePersonalDetails) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypePersonalDetails{}
)

func (p *PassportElementTypePersonalDetails) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypePersonalDetails) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypePersonalDetails",
		ID:   PassportElementTypePersonalDetailsTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypePersonalDetails) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePersonalDetails#c27ad953 as nil")
	}
	b.PutID(PassportElementTypePersonalDetailsTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypePersonalDetails) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePersonalDetails#c27ad953 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypePersonalDetails) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePersonalDetails#c27ad953 to nil")
	}
	if err := b.ConsumeID(PassportElementTypePersonalDetailsTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypePersonalDetails#c27ad953: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypePersonalDetails) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePersonalDetails#c27ad953 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypePersonalDetails) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePersonalDetails#c27ad953 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypePersonalDetails")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypePersonalDetails) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePersonalDetails#c27ad953 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypePersonalDetails"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypePersonalDetails#c27ad953: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypePassport represents TL type `passportElementTypePassport#e5fdab48`.
type PassportElementTypePassport struct {
}

// PassportElementTypePassportTypeID is TL type id of PassportElementTypePassport.
const PassportElementTypePassportTypeID = 0xe5fdab48

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypePassport) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypePassport{}
)

func (p *PassportElementTypePassport) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypePassport) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypePassport",
		ID:   PassportElementTypePassportTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypePassport) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassport#e5fdab48 as nil")
	}
	b.PutID(PassportElementTypePassportTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypePassport) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassport#e5fdab48 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypePassport) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassport#e5fdab48 to nil")
	}
	if err := b.ConsumeID(PassportElementTypePassportTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypePassport#e5fdab48: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypePassport) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassport#e5fdab48 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypePassport) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassport#e5fdab48 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypePassport")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypePassport) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassport#e5fdab48 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypePassport"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypePassport#e5fdab48: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeDriverLicense represents TL type `passportElementTypeDriverLicense#6cea5c4b`.
type PassportElementTypeDriverLicense struct {
}

// PassportElementTypeDriverLicenseTypeID is TL type id of PassportElementTypeDriverLicense.
const PassportElementTypeDriverLicenseTypeID = 0x6cea5c4b

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeDriverLicense) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeDriverLicense{}
)

func (p *PassportElementTypeDriverLicense) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeDriverLicense) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeDriverLicense",
		ID:   PassportElementTypeDriverLicenseTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeDriverLicense) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeDriverLicense#6cea5c4b as nil")
	}
	b.PutID(PassportElementTypeDriverLicenseTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeDriverLicense) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeDriverLicense#6cea5c4b as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeDriverLicense) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeDriverLicense#6cea5c4b to nil")
	}
	if err := b.ConsumeID(PassportElementTypeDriverLicenseTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeDriverLicense#6cea5c4b: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeDriverLicense) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeDriverLicense#6cea5c4b to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeDriverLicense) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeDriverLicense#6cea5c4b as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeDriverLicense")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeDriverLicense) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeDriverLicense#6cea5c4b to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeDriverLicense"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeDriverLicense#6cea5c4b: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeIdentityCard represents TL type `passportElementTypeIdentityCard#e20ea75c`.
type PassportElementTypeIdentityCard struct {
}

// PassportElementTypeIdentityCardTypeID is TL type id of PassportElementTypeIdentityCard.
const PassportElementTypeIdentityCardTypeID = 0xe20ea75c

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeIdentityCard) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeIdentityCard{}
)

func (p *PassportElementTypeIdentityCard) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeIdentityCard) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeIdentityCard",
		ID:   PassportElementTypeIdentityCardTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeIdentityCard) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeIdentityCard#e20ea75c as nil")
	}
	b.PutID(PassportElementTypeIdentityCardTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeIdentityCard) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeIdentityCard#e20ea75c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeIdentityCard) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeIdentityCard#e20ea75c to nil")
	}
	if err := b.ConsumeID(PassportElementTypeIdentityCardTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeIdentityCard#e20ea75c: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeIdentityCard) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeIdentityCard#e20ea75c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeIdentityCard) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeIdentityCard#e20ea75c as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeIdentityCard")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeIdentityCard) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeIdentityCard#e20ea75c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeIdentityCard"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeIdentityCard#e20ea75c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeInternalPassport represents TL type `passportElementTypeInternalPassport#d0afd939`.
type PassportElementTypeInternalPassport struct {
}

// PassportElementTypeInternalPassportTypeID is TL type id of PassportElementTypeInternalPassport.
const PassportElementTypeInternalPassportTypeID = 0xd0afd939

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeInternalPassport) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeInternalPassport{}
)

func (p *PassportElementTypeInternalPassport) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeInternalPassport) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeInternalPassport",
		ID:   PassportElementTypeInternalPassportTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeInternalPassport) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeInternalPassport#d0afd939 as nil")
	}
	b.PutID(PassportElementTypeInternalPassportTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeInternalPassport) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeInternalPassport#d0afd939 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeInternalPassport) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeInternalPassport#d0afd939 to nil")
	}
	if err := b.ConsumeID(PassportElementTypeInternalPassportTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeInternalPassport#d0afd939: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeInternalPassport) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeInternalPassport#d0afd939 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeInternalPassport) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeInternalPassport#d0afd939 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeInternalPassport")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeInternalPassport) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeInternalPassport#d0afd939 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeInternalPassport"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeInternalPassport#d0afd939: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeAddress represents TL type `passportElementTypeAddress#1d955cc2`.
type PassportElementTypeAddress struct {
}

// PassportElementTypeAddressTypeID is TL type id of PassportElementTypeAddress.
const PassportElementTypeAddressTypeID = 0x1d955cc2

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeAddress) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeAddress{}
)

func (p *PassportElementTypeAddress) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeAddress) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeAddress",
		ID:   PassportElementTypeAddressTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeAddress) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeAddress#1d955cc2 as nil")
	}
	b.PutID(PassportElementTypeAddressTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeAddress) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeAddress#1d955cc2 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeAddress) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeAddress#1d955cc2 to nil")
	}
	if err := b.ConsumeID(PassportElementTypeAddressTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeAddress#1d955cc2: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeAddress) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeAddress#1d955cc2 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeAddress) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeAddress#1d955cc2 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeAddress")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeAddress) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeAddress#1d955cc2 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeAddress"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeAddress#1d955cc2: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeUtilityBill represents TL type `passportElementTypeUtilityBill#25608e6a`.
type PassportElementTypeUtilityBill struct {
}

// PassportElementTypeUtilityBillTypeID is TL type id of PassportElementTypeUtilityBill.
const PassportElementTypeUtilityBillTypeID = 0x25608e6a

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeUtilityBill) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeUtilityBill{}
)

func (p *PassportElementTypeUtilityBill) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeUtilityBill) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeUtilityBill",
		ID:   PassportElementTypeUtilityBillTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeUtilityBill) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeUtilityBill#25608e6a as nil")
	}
	b.PutID(PassportElementTypeUtilityBillTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeUtilityBill) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeUtilityBill#25608e6a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeUtilityBill) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeUtilityBill#25608e6a to nil")
	}
	if err := b.ConsumeID(PassportElementTypeUtilityBillTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeUtilityBill#25608e6a: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeUtilityBill) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeUtilityBill#25608e6a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeUtilityBill) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeUtilityBill#25608e6a as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeUtilityBill")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeUtilityBill) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeUtilityBill#25608e6a to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeUtilityBill"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeUtilityBill#25608e6a: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeBankStatement represents TL type `passportElementTypeBankStatement#22380133`.
type PassportElementTypeBankStatement struct {
}

// PassportElementTypeBankStatementTypeID is TL type id of PassportElementTypeBankStatement.
const PassportElementTypeBankStatementTypeID = 0x22380133

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeBankStatement) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeBankStatement{}
)

func (p *PassportElementTypeBankStatement) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeBankStatement) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeBankStatement",
		ID:   PassportElementTypeBankStatementTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeBankStatement) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeBankStatement#22380133 as nil")
	}
	b.PutID(PassportElementTypeBankStatementTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeBankStatement) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeBankStatement#22380133 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeBankStatement) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeBankStatement#22380133 to nil")
	}
	if err := b.ConsumeID(PassportElementTypeBankStatementTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeBankStatement#22380133: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeBankStatement) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeBankStatement#22380133 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeBankStatement) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeBankStatement#22380133 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeBankStatement")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeBankStatement) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeBankStatement#22380133 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeBankStatement"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeBankStatement#22380133: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeRentalAgreement represents TL type `passportElementTypeRentalAgreement#852dfe90`.
type PassportElementTypeRentalAgreement struct {
}

// PassportElementTypeRentalAgreementTypeID is TL type id of PassportElementTypeRentalAgreement.
const PassportElementTypeRentalAgreementTypeID = 0x852dfe90

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeRentalAgreement) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeRentalAgreement{}
)

func (p *PassportElementTypeRentalAgreement) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeRentalAgreement) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeRentalAgreement",
		ID:   PassportElementTypeRentalAgreementTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeRentalAgreement) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeRentalAgreement#852dfe90 as nil")
	}
	b.PutID(PassportElementTypeRentalAgreementTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeRentalAgreement) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeRentalAgreement#852dfe90 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeRentalAgreement) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeRentalAgreement#852dfe90 to nil")
	}
	if err := b.ConsumeID(PassportElementTypeRentalAgreementTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeRentalAgreement#852dfe90: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeRentalAgreement) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeRentalAgreement#852dfe90 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeRentalAgreement) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeRentalAgreement#852dfe90 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeRentalAgreement")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeRentalAgreement) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeRentalAgreement#852dfe90 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeRentalAgreement"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeRentalAgreement#852dfe90: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypePassportRegistration represents TL type `passportElementTypePassportRegistration#f67e8e3f`.
type PassportElementTypePassportRegistration struct {
}

// PassportElementTypePassportRegistrationTypeID is TL type id of PassportElementTypePassportRegistration.
const PassportElementTypePassportRegistrationTypeID = 0xf67e8e3f

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypePassportRegistration) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypePassportRegistration{}
)

func (p *PassportElementTypePassportRegistration) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypePassportRegistration) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypePassportRegistration",
		ID:   PassportElementTypePassportRegistrationTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypePassportRegistration) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassportRegistration#f67e8e3f as nil")
	}
	b.PutID(PassportElementTypePassportRegistrationTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypePassportRegistration) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassportRegistration#f67e8e3f as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypePassportRegistration) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassportRegistration#f67e8e3f to nil")
	}
	if err := b.ConsumeID(PassportElementTypePassportRegistrationTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypePassportRegistration#f67e8e3f: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypePassportRegistration) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassportRegistration#f67e8e3f to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypePassportRegistration) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePassportRegistration#f67e8e3f as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypePassportRegistration")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypePassportRegistration) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePassportRegistration#f67e8e3f to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypePassportRegistration"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypePassportRegistration#f67e8e3f: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeTemporaryRegistration represents TL type `passportElementTypeTemporaryRegistration#411e345f`.
type PassportElementTypeTemporaryRegistration struct {
}

// PassportElementTypeTemporaryRegistrationTypeID is TL type id of PassportElementTypeTemporaryRegistration.
const PassportElementTypeTemporaryRegistrationTypeID = 0x411e345f

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeTemporaryRegistration) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeTemporaryRegistration{}
)

func (p *PassportElementTypeTemporaryRegistration) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeTemporaryRegistration) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeTemporaryRegistration",
		ID:   PassportElementTypeTemporaryRegistrationTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeTemporaryRegistration) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeTemporaryRegistration#411e345f as nil")
	}
	b.PutID(PassportElementTypeTemporaryRegistrationTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeTemporaryRegistration) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeTemporaryRegistration#411e345f as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeTemporaryRegistration) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeTemporaryRegistration#411e345f to nil")
	}
	if err := b.ConsumeID(PassportElementTypeTemporaryRegistrationTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeTemporaryRegistration#411e345f: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeTemporaryRegistration) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeTemporaryRegistration#411e345f to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeTemporaryRegistration) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeTemporaryRegistration#411e345f as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeTemporaryRegistration")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeTemporaryRegistration) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeTemporaryRegistration#411e345f to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeTemporaryRegistration"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeTemporaryRegistration#411e345f: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypePhoneNumber represents TL type `passportElementTypePhoneNumber#c4abfe6c`.
type PassportElementTypePhoneNumber struct {
}

// PassportElementTypePhoneNumberTypeID is TL type id of PassportElementTypePhoneNumber.
const PassportElementTypePhoneNumberTypeID = 0xc4abfe6c

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypePhoneNumber) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypePhoneNumber{}
)

func (p *PassportElementTypePhoneNumber) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypePhoneNumber) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypePhoneNumber",
		ID:   PassportElementTypePhoneNumberTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypePhoneNumber) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePhoneNumber#c4abfe6c as nil")
	}
	b.PutID(PassportElementTypePhoneNumberTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypePhoneNumber) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePhoneNumber#c4abfe6c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypePhoneNumber) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePhoneNumber#c4abfe6c to nil")
	}
	if err := b.ConsumeID(PassportElementTypePhoneNumberTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypePhoneNumber#c4abfe6c: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypePhoneNumber) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePhoneNumber#c4abfe6c to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypePhoneNumber) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypePhoneNumber#c4abfe6c as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypePhoneNumber")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypePhoneNumber) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypePhoneNumber#c4abfe6c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypePhoneNumber"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypePhoneNumber#c4abfe6c: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeEmailAddress represents TL type `passportElementTypeEmailAddress#fb45a6c3`.
type PassportElementTypeEmailAddress struct {
}

// PassportElementTypeEmailAddressTypeID is TL type id of PassportElementTypeEmailAddress.
const PassportElementTypeEmailAddressTypeID = 0xfb45a6c3

// construct implements constructor of PassportElementTypeClass.
func (p PassportElementTypeEmailAddress) construct() PassportElementTypeClass { return &p }

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

	_ PassportElementTypeClass = &PassportElementTypeEmailAddress{}
)

func (p *PassportElementTypeEmailAddress) Zero() bool {
	if p == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (p *PassportElementTypeEmailAddress) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "passportElementTypeEmailAddress",
		ID:   PassportElementTypeEmailAddressTypeID,
	}
	if p == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (p *PassportElementTypeEmailAddress) Encode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeEmailAddress#fb45a6c3 as nil")
	}
	b.PutID(PassportElementTypeEmailAddressTypeID)
	return p.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (p *PassportElementTypeEmailAddress) EncodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeEmailAddress#fb45a6c3 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (p *PassportElementTypeEmailAddress) Decode(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeEmailAddress#fb45a6c3 to nil")
	}
	if err := b.ConsumeID(PassportElementTypeEmailAddressTypeID); err != nil {
		return fmt.Errorf("unable to decode passportElementTypeEmailAddress#fb45a6c3: %w", err)
	}
	return p.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (p *PassportElementTypeEmailAddress) DecodeBare(b *bin.Buffer) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeEmailAddress#fb45a6c3 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (p *PassportElementTypeEmailAddress) EncodeTDLibJSON(b tdjson.Encoder) error {
	if p == nil {
		return fmt.Errorf("can't encode passportElementTypeEmailAddress#fb45a6c3 as nil")
	}
	b.ObjStart()
	b.PutID("passportElementTypeEmailAddress")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (p *PassportElementTypeEmailAddress) DecodeTDLibJSON(b tdjson.Decoder) error {
	if p == nil {
		return fmt.Errorf("can't decode passportElementTypeEmailAddress#fb45a6c3 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("passportElementTypeEmailAddress"); err != nil {
				return fmt.Errorf("unable to decode passportElementTypeEmailAddress#fb45a6c3: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// PassportElementTypeClassName is schema name of PassportElementTypeClass.
const PassportElementTypeClassName = "PassportElementType"

// PassportElementTypeClass represents PassportElementType generic type.
//
// Example:
//
//	g, err := tdapi.DecodePassportElementType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.PassportElementTypePersonalDetails: // passportElementTypePersonalDetails#c27ad953
//	case *tdapi.PassportElementTypePassport: // passportElementTypePassport#e5fdab48
//	case *tdapi.PassportElementTypeDriverLicense: // passportElementTypeDriverLicense#6cea5c4b
//	case *tdapi.PassportElementTypeIdentityCard: // passportElementTypeIdentityCard#e20ea75c
//	case *tdapi.PassportElementTypeInternalPassport: // passportElementTypeInternalPassport#d0afd939
//	case *tdapi.PassportElementTypeAddress: // passportElementTypeAddress#1d955cc2
//	case *tdapi.PassportElementTypeUtilityBill: // passportElementTypeUtilityBill#25608e6a
//	case *tdapi.PassportElementTypeBankStatement: // passportElementTypeBankStatement#22380133
//	case *tdapi.PassportElementTypeRentalAgreement: // passportElementTypeRentalAgreement#852dfe90
//	case *tdapi.PassportElementTypePassportRegistration: // passportElementTypePassportRegistration#f67e8e3f
//	case *tdapi.PassportElementTypeTemporaryRegistration: // passportElementTypeTemporaryRegistration#411e345f
//	case *tdapi.PassportElementTypePhoneNumber: // passportElementTypePhoneNumber#c4abfe6c
//	case *tdapi.PassportElementTypeEmailAddress: // passportElementTypeEmailAddress#fb45a6c3
//	default: panic(v)
//	}
type PassportElementTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PassportElementTypeClass

	// 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

	EncodeTDLibJSON(b tdjson.Encoder) error
	DecodeTDLibJSON(b tdjson.Decoder) error
}

// DecodePassportElementType implements binary de-serialization for PassportElementTypeClass.
func DecodePassportElementType(buf *bin.Buffer) (PassportElementTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case PassportElementTypePersonalDetailsTypeID:
		// Decoding passportElementTypePersonalDetails#c27ad953.
		v := PassportElementTypePersonalDetails{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypePassportTypeID:
		// Decoding passportElementTypePassport#e5fdab48.
		v := PassportElementTypePassport{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeDriverLicenseTypeID:
		// Decoding passportElementTypeDriverLicense#6cea5c4b.
		v := PassportElementTypeDriverLicense{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeIdentityCardTypeID:
		// Decoding passportElementTypeIdentityCard#e20ea75c.
		v := PassportElementTypeIdentityCard{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeInternalPassportTypeID:
		// Decoding passportElementTypeInternalPassport#d0afd939.
		v := PassportElementTypeInternalPassport{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeAddressTypeID:
		// Decoding passportElementTypeAddress#1d955cc2.
		v := PassportElementTypeAddress{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeUtilityBillTypeID:
		// Decoding passportElementTypeUtilityBill#25608e6a.
		v := PassportElementTypeUtilityBill{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeBankStatementTypeID:
		// Decoding passportElementTypeBankStatement#22380133.
		v := PassportElementTypeBankStatement{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeRentalAgreementTypeID:
		// Decoding passportElementTypeRentalAgreement#852dfe90.
		v := PassportElementTypeRentalAgreement{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypePassportRegistrationTypeID:
		// Decoding passportElementTypePassportRegistration#f67e8e3f.
		v := PassportElementTypePassportRegistration{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeTemporaryRegistrationTypeID:
		// Decoding passportElementTypeTemporaryRegistration#411e345f.
		v := PassportElementTypeTemporaryRegistration{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypePhoneNumberTypeID:
		// Decoding passportElementTypePhoneNumber#c4abfe6c.
		v := PassportElementTypePhoneNumber{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case PassportElementTypeEmailAddressTypeID:
		// Decoding passportElementTypeEmailAddress#fb45a6c3.
		v := PassportElementTypeEmailAddress{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONPassportElementType implements binary de-serialization for PassportElementTypeClass.
func DecodeTDLibJSONPassportElementType(buf tdjson.Decoder) (PassportElementTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "passportElementTypePersonalDetails":
		// Decoding passportElementTypePersonalDetails#c27ad953.
		v := PassportElementTypePersonalDetails{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypePassport":
		// Decoding passportElementTypePassport#e5fdab48.
		v := PassportElementTypePassport{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeDriverLicense":
		// Decoding passportElementTypeDriverLicense#6cea5c4b.
		v := PassportElementTypeDriverLicense{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeIdentityCard":
		// Decoding passportElementTypeIdentityCard#e20ea75c.
		v := PassportElementTypeIdentityCard{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeInternalPassport":
		// Decoding passportElementTypeInternalPassport#d0afd939.
		v := PassportElementTypeInternalPassport{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeAddress":
		// Decoding passportElementTypeAddress#1d955cc2.
		v := PassportElementTypeAddress{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeUtilityBill":
		// Decoding passportElementTypeUtilityBill#25608e6a.
		v := PassportElementTypeUtilityBill{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeBankStatement":
		// Decoding passportElementTypeBankStatement#22380133.
		v := PassportElementTypeBankStatement{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeRentalAgreement":
		// Decoding passportElementTypeRentalAgreement#852dfe90.
		v := PassportElementTypeRentalAgreement{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypePassportRegistration":
		// Decoding passportElementTypePassportRegistration#f67e8e3f.
		v := PassportElementTypePassportRegistration{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeTemporaryRegistration":
		// Decoding passportElementTypeTemporaryRegistration#411e345f.
		v := PassportElementTypeTemporaryRegistration{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypePhoneNumber":
		// Decoding passportElementTypePhoneNumber#c4abfe6c.
		v := PassportElementTypePhoneNumber{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	case "passportElementTypeEmailAddress":
		// Decoding passportElementTypeEmailAddress#fb45a6c3.
		v := PassportElementTypeEmailAddress{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode PassportElementTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// PassportElementType boxes the PassportElementTypeClass providing a helper.
type PassportElementTypeBox struct {
	PassportElementType PassportElementTypeClass
}

// Decode implements bin.Decoder for PassportElementTypeBox.
func (b *PassportElementTypeBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode PassportElementTypeBox to nil")
	}
	v, err := DecodePassportElementType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.PassportElementType = v
	return nil
}

// Encode implements bin.Encode for PassportElementTypeBox.
func (b *PassportElementTypeBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.PassportElementType == nil {
		return fmt.Errorf("unable to encode PassportElementTypeClass as nil")
	}
	return b.PassportElementType.Encode(buf)
}

// DecodeTDLibJSON implements bin.Decoder for PassportElementTypeBox.
func (b *PassportElementTypeBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode PassportElementTypeBox to nil")
	}
	v, err := DecodeTDLibJSONPassportElementType(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.PassportElementType = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for PassportElementTypeBox.
func (b *PassportElementTypeBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.PassportElementType == nil {
		return fmt.Errorf("unable to encode PassportElementTypeClass as nil")
	}
	return b.PassportElementType.EncodeTDLibJSON(buf)
}
