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

// CallProblemEcho represents TL type `callProblemEcho#2fc01184`.
type CallProblemEcho struct {
}

// CallProblemEchoTypeID is TL type id of CallProblemEcho.
const CallProblemEchoTypeID = 0x2fc01184

// construct implements constructor of CallProblemClass.
func (c CallProblemEcho) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemEcho{}
)

func (c *CallProblemEcho) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemEcho) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemEcho#2fc01184 as nil")
	}
	b.PutID(CallProblemEchoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemEcho) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemEcho#2fc01184 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemEcho) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemEcho#2fc01184 to nil")
	}
	if err := b.ConsumeID(CallProblemEchoTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemEcho#2fc01184: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemEcho) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemEcho#2fc01184 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemEcho) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemEcho#2fc01184 as nil")
	}
	b.ObjStart()
	b.PutID("callProblemEcho")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemEcho) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemEcho#2fc01184 to nil")
	}

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

// CallProblemNoise represents TL type `callProblemNoise#3ec4808f`.
type CallProblemNoise struct {
}

// CallProblemNoiseTypeID is TL type id of CallProblemNoise.
const CallProblemNoiseTypeID = 0x3ec4808f

// construct implements constructor of CallProblemClass.
func (c CallProblemNoise) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemNoise{}
)

func (c *CallProblemNoise) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemNoise) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemNoise#3ec4808f as nil")
	}
	b.PutID(CallProblemNoiseTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemNoise) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemNoise#3ec4808f as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemNoise) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemNoise#3ec4808f to nil")
	}
	if err := b.ConsumeID(CallProblemNoiseTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemNoise#3ec4808f: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemNoise) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemNoise#3ec4808f to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemNoise) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemNoise#3ec4808f as nil")
	}
	b.ObjStart()
	b.PutID("callProblemNoise")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemNoise) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemNoise#3ec4808f to nil")
	}

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

// CallProblemInterruptions represents TL type `callProblemInterruptions#42ba1c62`.
type CallProblemInterruptions struct {
}

// CallProblemInterruptionsTypeID is TL type id of CallProblemInterruptions.
const CallProblemInterruptionsTypeID = 0x42ba1c62

// construct implements constructor of CallProblemClass.
func (c CallProblemInterruptions) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemInterruptions{}
)

func (c *CallProblemInterruptions) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemInterruptions) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemInterruptions#42ba1c62 as nil")
	}
	b.PutID(CallProblemInterruptionsTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemInterruptions) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemInterruptions#42ba1c62 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemInterruptions) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemInterruptions#42ba1c62 to nil")
	}
	if err := b.ConsumeID(CallProblemInterruptionsTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemInterruptions#42ba1c62: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemInterruptions) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemInterruptions#42ba1c62 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemInterruptions) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemInterruptions#42ba1c62 as nil")
	}
	b.ObjStart()
	b.PutID("callProblemInterruptions")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemInterruptions) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemInterruptions#42ba1c62 to nil")
	}

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

// CallProblemDistortedSpeech represents TL type `callProblemDistortedSpeech#16a5bd05`.
type CallProblemDistortedSpeech struct {
}

// CallProblemDistortedSpeechTypeID is TL type id of CallProblemDistortedSpeech.
const CallProblemDistortedSpeechTypeID = 0x16a5bd05

// construct implements constructor of CallProblemClass.
func (c CallProblemDistortedSpeech) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemDistortedSpeech{}
)

func (c *CallProblemDistortedSpeech) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemDistortedSpeech) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedSpeech#16a5bd05 as nil")
	}
	b.PutID(CallProblemDistortedSpeechTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemDistortedSpeech) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedSpeech#16a5bd05 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemDistortedSpeech) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedSpeech#16a5bd05 to nil")
	}
	if err := b.ConsumeID(CallProblemDistortedSpeechTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemDistortedSpeech#16a5bd05: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemDistortedSpeech) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedSpeech#16a5bd05 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemDistortedSpeech) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedSpeech#16a5bd05 as nil")
	}
	b.ObjStart()
	b.PutID("callProblemDistortedSpeech")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemDistortedSpeech) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedSpeech#16a5bd05 to nil")
	}

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

// CallProblemSilentLocal represents TL type `callProblemSilentLocal#f1e6f36`.
type CallProblemSilentLocal struct {
}

// CallProblemSilentLocalTypeID is TL type id of CallProblemSilentLocal.
const CallProblemSilentLocalTypeID = 0xf1e6f36

// construct implements constructor of CallProblemClass.
func (c CallProblemSilentLocal) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemSilentLocal{}
)

func (c *CallProblemSilentLocal) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemSilentLocal) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemSilentLocal#f1e6f36 as nil")
	}
	b.PutID(CallProblemSilentLocalTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemSilentLocal) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemSilentLocal#f1e6f36 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemSilentLocal) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentLocal#f1e6f36 to nil")
	}
	if err := b.ConsumeID(CallProblemSilentLocalTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemSilentLocal#f1e6f36: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemSilentLocal) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentLocal#f1e6f36 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemSilentLocal) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentLocal#f1e6f36 to nil")
	}

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

// CallProblemSilentRemote represents TL type `callProblemSilentRemote#2230f89a`.
type CallProblemSilentRemote struct {
}

// CallProblemSilentRemoteTypeID is TL type id of CallProblemSilentRemote.
const CallProblemSilentRemoteTypeID = 0x2230f89a

// construct implements constructor of CallProblemClass.
func (c CallProblemSilentRemote) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemSilentRemote{}
)

func (c *CallProblemSilentRemote) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemSilentRemote) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemSilentRemote#2230f89a as nil")
	}
	b.PutID(CallProblemSilentRemoteTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemSilentRemote) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemSilentRemote#2230f89a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemSilentRemote) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentRemote#2230f89a to nil")
	}
	if err := b.ConsumeID(CallProblemSilentRemoteTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemSilentRemote#2230f89a: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemSilentRemote) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentRemote#2230f89a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemSilentRemote) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemSilentRemote#2230f89a as nil")
	}
	b.ObjStart()
	b.PutID("callProblemSilentRemote")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemSilentRemote) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemSilentRemote#2230f89a to nil")
	}

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

// CallProblemDropped represents TL type `callProblemDropped#b809e381`.
type CallProblemDropped struct {
}

// CallProblemDroppedTypeID is TL type id of CallProblemDropped.
const CallProblemDroppedTypeID = 0xb809e381

// construct implements constructor of CallProblemClass.
func (c CallProblemDropped) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemDropped{}
)

func (c *CallProblemDropped) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemDropped) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDropped#b809e381 as nil")
	}
	b.PutID(CallProblemDroppedTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemDropped) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDropped#b809e381 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemDropped) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDropped#b809e381 to nil")
	}
	if err := b.ConsumeID(CallProblemDroppedTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemDropped#b809e381: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemDropped) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDropped#b809e381 to nil")
	}
	return nil
}

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

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemDropped) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDropped#b809e381 to nil")
	}

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

// CallProblemDistortedVideo represents TL type `callProblemDistortedVideo#16f6620a`.
type CallProblemDistortedVideo struct {
}

// CallProblemDistortedVideoTypeID is TL type id of CallProblemDistortedVideo.
const CallProblemDistortedVideoTypeID = 0x16f6620a

// construct implements constructor of CallProblemClass.
func (c CallProblemDistortedVideo) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemDistortedVideo{}
)

func (c *CallProblemDistortedVideo) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemDistortedVideo) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedVideo#16f6620a as nil")
	}
	b.PutID(CallProblemDistortedVideoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemDistortedVideo) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedVideo#16f6620a as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemDistortedVideo) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedVideo#16f6620a to nil")
	}
	if err := b.ConsumeID(CallProblemDistortedVideoTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemDistortedVideo#16f6620a: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemDistortedVideo) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedVideo#16f6620a to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemDistortedVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemDistortedVideo#16f6620a as nil")
	}
	b.ObjStart()
	b.PutID("callProblemDistortedVideo")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemDistortedVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemDistortedVideo#16f6620a to nil")
	}

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

// CallProblemPixelatedVideo represents TL type `callProblemPixelatedVideo#7e1526d3`.
type CallProblemPixelatedVideo struct {
}

// CallProblemPixelatedVideoTypeID is TL type id of CallProblemPixelatedVideo.
const CallProblemPixelatedVideoTypeID = 0x7e1526d3

// construct implements constructor of CallProblemClass.
func (c CallProblemPixelatedVideo) construct() CallProblemClass { return &c }

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

	_ CallProblemClass = &CallProblemPixelatedVideo{}
)

func (c *CallProblemPixelatedVideo) Zero() bool {
	if c == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (c *CallProblemPixelatedVideo) Encode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemPixelatedVideo#7e1526d3 as nil")
	}
	b.PutID(CallProblemPixelatedVideoTypeID)
	return c.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (c *CallProblemPixelatedVideo) EncodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemPixelatedVideo#7e1526d3 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (c *CallProblemPixelatedVideo) Decode(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemPixelatedVideo#7e1526d3 to nil")
	}
	if err := b.ConsumeID(CallProblemPixelatedVideoTypeID); err != nil {
		return fmt.Errorf("unable to decode callProblemPixelatedVideo#7e1526d3: %w", err)
	}
	return c.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (c *CallProblemPixelatedVideo) DecodeBare(b *bin.Buffer) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemPixelatedVideo#7e1526d3 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (c *CallProblemPixelatedVideo) EncodeTDLibJSON(b tdjson.Encoder) error {
	if c == nil {
		return fmt.Errorf("can't encode callProblemPixelatedVideo#7e1526d3 as nil")
	}
	b.ObjStart()
	b.PutID("callProblemPixelatedVideo")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (c *CallProblemPixelatedVideo) DecodeTDLibJSON(b tdjson.Decoder) error {
	if c == nil {
		return fmt.Errorf("can't decode callProblemPixelatedVideo#7e1526d3 to nil")
	}

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

// CallProblemClassName is schema name of CallProblemClass.
const CallProblemClassName = "CallProblem"

// CallProblemClass represents CallProblem generic type.
//
// Example:
//
//	g, err := tdapi.DecodeCallProblem(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.CallProblemEcho: // callProblemEcho#2fc01184
//	case *tdapi.CallProblemNoise: // callProblemNoise#3ec4808f
//	case *tdapi.CallProblemInterruptions: // callProblemInterruptions#42ba1c62
//	case *tdapi.CallProblemDistortedSpeech: // callProblemDistortedSpeech#16a5bd05
//	case *tdapi.CallProblemSilentLocal: // callProblemSilentLocal#f1e6f36
//	case *tdapi.CallProblemSilentRemote: // callProblemSilentRemote#2230f89a
//	case *tdapi.CallProblemDropped: // callProblemDropped#b809e381
//	case *tdapi.CallProblemDistortedVideo: // callProblemDistortedVideo#16f6620a
//	case *tdapi.CallProblemPixelatedVideo: // callProblemPixelatedVideo#7e1526d3
//	default: panic(v)
//	}
type CallProblemClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() CallProblemClass

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

// DecodeCallProblem implements binary de-serialization for CallProblemClass.
func DecodeCallProblem(buf *bin.Buffer) (CallProblemClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case CallProblemEchoTypeID:
		// Decoding callProblemEcho#2fc01184.
		v := CallProblemEcho{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemNoiseTypeID:
		// Decoding callProblemNoise#3ec4808f.
		v := CallProblemNoise{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemInterruptionsTypeID:
		// Decoding callProblemInterruptions#42ba1c62.
		v := CallProblemInterruptions{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemDistortedSpeechTypeID:
		// Decoding callProblemDistortedSpeech#16a5bd05.
		v := CallProblemDistortedSpeech{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemSilentLocalTypeID:
		// Decoding callProblemSilentLocal#f1e6f36.
		v := CallProblemSilentLocal{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemSilentRemoteTypeID:
		// Decoding callProblemSilentRemote#2230f89a.
		v := CallProblemSilentRemote{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemDroppedTypeID:
		// Decoding callProblemDropped#b809e381.
		v := CallProblemDropped{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemDistortedVideoTypeID:
		// Decoding callProblemDistortedVideo#16f6620a.
		v := CallProblemDistortedVideo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case CallProblemPixelatedVideoTypeID:
		// Decoding callProblemPixelatedVideo#7e1526d3.
		v := CallProblemPixelatedVideo{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode CallProblemClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONCallProblem implements binary de-serialization for CallProblemClass.
func DecodeTDLibJSONCallProblem(buf tdjson.Decoder) (CallProblemClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "callProblemEcho":
		// Decoding callProblemEcho#2fc01184.
		v := CallProblemEcho{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemNoise":
		// Decoding callProblemNoise#3ec4808f.
		v := CallProblemNoise{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemInterruptions":
		// Decoding callProblemInterruptions#42ba1c62.
		v := CallProblemInterruptions{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemDistortedSpeech":
		// Decoding callProblemDistortedSpeech#16a5bd05.
		v := CallProblemDistortedSpeech{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemSilentLocal":
		// Decoding callProblemSilentLocal#f1e6f36.
		v := CallProblemSilentLocal{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemSilentRemote":
		// Decoding callProblemSilentRemote#2230f89a.
		v := CallProblemSilentRemote{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemDropped":
		// Decoding callProblemDropped#b809e381.
		v := CallProblemDropped{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemDistortedVideo":
		// Decoding callProblemDistortedVideo#16f6620a.
		v := CallProblemDistortedVideo{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	case "callProblemPixelatedVideo":
		// Decoding callProblemPixelatedVideo#7e1526d3.
		v := CallProblemPixelatedVideo{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode CallProblemClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode CallProblemClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// CallProblem boxes the CallProblemClass providing a helper.
type CallProblemBox struct {
	CallProblem CallProblemClass
}

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

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

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

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