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

// PhoneCallDiscardReasonMissed represents TL type `phoneCallDiscardReasonMissed#85e42301`.
// The phone call was missed
//
// See https://core.telegram.org/constructor/phoneCallDiscardReasonMissed for reference.
type PhoneCallDiscardReasonMissed struct {
}

// PhoneCallDiscardReasonMissedTypeID is TL type id of PhoneCallDiscardReasonMissed.
const PhoneCallDiscardReasonMissedTypeID = 0x85e42301

// construct implements constructor of PhoneCallDiscardReasonClass.
func ( PhoneCallDiscardReasonMissed) () PhoneCallDiscardReasonClass { return & }

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

	_ PhoneCallDiscardReasonClass = &PhoneCallDiscardReasonMissed{}
)

func ( *PhoneCallDiscardReasonMissed) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *PhoneCallDiscardReasonMissed) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallDiscardReasonMissed",
		ID:   PhoneCallDiscardReasonMissedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneCallDiscardReasonMissed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonMissed#85e42301 as nil")
	}
	.PutID(PhoneCallDiscardReasonMissedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallDiscardReasonMissed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonMissed#85e42301 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallDiscardReasonMissed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonMissed#85e42301 to nil")
	}
	if  := .ConsumeID(PhoneCallDiscardReasonMissedTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallDiscardReasonMissed#85e42301: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallDiscardReasonMissed) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonMissed#85e42301 to nil")
	}
	return nil
}

// PhoneCallDiscardReasonDisconnect represents TL type `phoneCallDiscardReasonDisconnect#e095c1a0`.
// The phone call was disconnected
//
// See https://core.telegram.org/constructor/phoneCallDiscardReasonDisconnect for reference.
type PhoneCallDiscardReasonDisconnect struct {
}

// PhoneCallDiscardReasonDisconnectTypeID is TL type id of PhoneCallDiscardReasonDisconnect.
const PhoneCallDiscardReasonDisconnectTypeID = 0xe095c1a0

// construct implements constructor of PhoneCallDiscardReasonClass.
func ( PhoneCallDiscardReasonDisconnect) () PhoneCallDiscardReasonClass { return & }

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

	_ PhoneCallDiscardReasonClass = &PhoneCallDiscardReasonDisconnect{}
)

func ( *PhoneCallDiscardReasonDisconnect) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *PhoneCallDiscardReasonDisconnect) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallDiscardReasonDisconnect",
		ID:   PhoneCallDiscardReasonDisconnectTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneCallDiscardReasonDisconnect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonDisconnect#e095c1a0 as nil")
	}
	.PutID(PhoneCallDiscardReasonDisconnectTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallDiscardReasonDisconnect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonDisconnect#e095c1a0 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallDiscardReasonDisconnect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonDisconnect#e095c1a0 to nil")
	}
	return nil
}

// PhoneCallDiscardReasonHangup represents TL type `phoneCallDiscardReasonHangup#57adc690`.
// The phone call was ended normally
//
// See https://core.telegram.org/constructor/phoneCallDiscardReasonHangup for reference.
type PhoneCallDiscardReasonHangup struct {
}

// PhoneCallDiscardReasonHangupTypeID is TL type id of PhoneCallDiscardReasonHangup.
const PhoneCallDiscardReasonHangupTypeID = 0x57adc690

// construct implements constructor of PhoneCallDiscardReasonClass.
func ( PhoneCallDiscardReasonHangup) () PhoneCallDiscardReasonClass { return & }

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

	_ PhoneCallDiscardReasonClass = &PhoneCallDiscardReasonHangup{}
)

func ( *PhoneCallDiscardReasonHangup) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *PhoneCallDiscardReasonHangup) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallDiscardReasonHangup",
		ID:   PhoneCallDiscardReasonHangupTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneCallDiscardReasonHangup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonHangup#57adc690 as nil")
	}
	.PutID(PhoneCallDiscardReasonHangupTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallDiscardReasonHangup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonHangup#57adc690 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhoneCallDiscardReasonHangup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonHangup#57adc690 to nil")
	}
	if  := .ConsumeID(PhoneCallDiscardReasonHangupTypeID);  != nil {
		return fmt.Errorf("unable to decode phoneCallDiscardReasonHangup#57adc690: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallDiscardReasonHangup) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonHangup#57adc690 to nil")
	}
	return nil
}

// PhoneCallDiscardReasonBusy represents TL type `phoneCallDiscardReasonBusy#faf7e8c9`.
// The phone call was discarded because the user is busy in another call
//
// See https://core.telegram.org/constructor/phoneCallDiscardReasonBusy for reference.
type PhoneCallDiscardReasonBusy struct {
}

// PhoneCallDiscardReasonBusyTypeID is TL type id of PhoneCallDiscardReasonBusy.
const PhoneCallDiscardReasonBusyTypeID = 0xfaf7e8c9

// construct implements constructor of PhoneCallDiscardReasonClass.
func ( PhoneCallDiscardReasonBusy) () PhoneCallDiscardReasonClass { return & }

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

	_ PhoneCallDiscardReasonClass = &PhoneCallDiscardReasonBusy{}
)

func ( *PhoneCallDiscardReasonBusy) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *PhoneCallDiscardReasonBusy) () tdp.Type {
	 := tdp.Type{
		Name: "phoneCallDiscardReasonBusy",
		ID:   PhoneCallDiscardReasonBusyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *PhoneCallDiscardReasonBusy) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonBusy#faf7e8c9 as nil")
	}
	.PutID(PhoneCallDiscardReasonBusyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhoneCallDiscardReasonBusy) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode phoneCallDiscardReasonBusy#faf7e8c9 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PhoneCallDiscardReasonBusy) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode phoneCallDiscardReasonBusy#faf7e8c9 to nil")
	}
	return nil
}

// PhoneCallDiscardReasonClassName is schema name of PhoneCallDiscardReasonClass.
const PhoneCallDiscardReasonClassName = "PhoneCallDiscardReason"

// PhoneCallDiscardReasonClass represents PhoneCallDiscardReason generic type.
//
// See https://core.telegram.org/type/PhoneCallDiscardReason for reference.
//
// Example:
//
//	g, err := tg.DecodePhoneCallDiscardReason(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PhoneCallDiscardReasonMissed: // phoneCallDiscardReasonMissed#85e42301
//	case *tg.PhoneCallDiscardReasonDisconnect: // phoneCallDiscardReasonDisconnect#e095c1a0
//	case *tg.PhoneCallDiscardReasonHangup: // phoneCallDiscardReasonHangup#57adc690
//	case *tg.PhoneCallDiscardReasonBusy: // phoneCallDiscardReasonBusy#faf7e8c9
//	default: panic(v)
//	}
type PhoneCallDiscardReasonClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PhoneCallDiscardReasonClass

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

// DecodePhoneCallDiscardReason implements binary de-serialization for PhoneCallDiscardReasonClass.
func ( *bin.Buffer) (PhoneCallDiscardReasonClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PhoneCallDiscardReasonMissedTypeID:
		// Decoding phoneCallDiscardReasonMissed#85e42301.
		 := PhoneCallDiscardReasonMissed{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallDiscardReasonClass: %w", )
		}
		return &, nil
	case PhoneCallDiscardReasonDisconnectTypeID:
		// Decoding phoneCallDiscardReasonDisconnect#e095c1a0.
		 := PhoneCallDiscardReasonDisconnect{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallDiscardReasonClass: %w", )
		}
		return &, nil
	case PhoneCallDiscardReasonHangupTypeID:
		// Decoding phoneCallDiscardReasonHangup#57adc690.
		 := PhoneCallDiscardReasonHangup{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallDiscardReasonClass: %w", )
		}
		return &, nil
	case PhoneCallDiscardReasonBusyTypeID:
		// Decoding phoneCallDiscardReasonBusy#faf7e8c9.
		 := PhoneCallDiscardReasonBusy{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PhoneCallDiscardReasonClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PhoneCallDiscardReasonClass: %w", bin.NewUnexpectedID())
	}
}

// PhoneCallDiscardReason boxes the PhoneCallDiscardReasonClass providing a helper.
type PhoneCallDiscardReasonBox struct {
	PhoneCallDiscardReason PhoneCallDiscardReasonClass
}

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

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