// Code generated by gotdgen, DO NOT EDIT.

package e2e

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

// DecryptedMessageActionSetMessageTTL represents TL type `decryptedMessageActionSetMessageTTL#a1733aec`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionSetMessageTTL for reference.
type DecryptedMessageActionSetMessageTTL struct {
	// TTLSeconds field of DecryptedMessageActionSetMessageTTL.
	TTLSeconds int
}

// DecryptedMessageActionSetMessageTTLTypeID is TL type id of DecryptedMessageActionSetMessageTTL.
const DecryptedMessageActionSetMessageTTLTypeID = 0xa1733aec

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionSetMessageTTL) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionSetMessageTTL{}
)

func (d *DecryptedMessageActionSetMessageTTL) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.TTLSeconds == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionSetMessageTTL) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionSetMessageTTL",
		ID:   DecryptedMessageActionSetMessageTTLTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "TTLSeconds",
			SchemaName: "ttl_seconds",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionSetMessageTTL) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionSetMessageTTL#a1733aec as nil")
	}
	b.PutID(DecryptedMessageActionSetMessageTTLTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionSetMessageTTL) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionSetMessageTTL#a1733aec as nil")
	}
	b.PutInt(d.TTLSeconds)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionSetMessageTTL) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionSetMessageTTL#a1733aec to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionSetMessageTTLTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionSetMessageTTL#a1733aec: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionSetMessageTTL) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionSetMessageTTL#a1733aec to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionSetMessageTTL#a1733aec: field ttl_seconds: %w", err)
		}
		d.TTLSeconds = value
	}
	return nil
}

// GetTTLSeconds returns value of TTLSeconds field.
func (d *DecryptedMessageActionSetMessageTTL) GetTTLSeconds() (value int) {
	if d == nil {
		return
	}
	return d.TTLSeconds
}

// DecryptedMessageActionReadMessages represents TL type `decryptedMessageActionReadMessages#c4f40be`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionReadMessages for reference.
type DecryptedMessageActionReadMessages struct {
	// RandomIDs field of DecryptedMessageActionReadMessages.
	RandomIDs []int64
}

// DecryptedMessageActionReadMessagesTypeID is TL type id of DecryptedMessageActionReadMessages.
const DecryptedMessageActionReadMessagesTypeID = 0xc4f40be

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionReadMessages) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionReadMessages{}
)

func (d *DecryptedMessageActionReadMessages) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomIDs == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionReadMessages) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionReadMessages",
		ID:   DecryptedMessageActionReadMessagesTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomIDs",
			SchemaName: "random_ids",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionReadMessages) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionReadMessages#c4f40be as nil")
	}
	b.PutID(DecryptedMessageActionReadMessagesTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionReadMessages) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionReadMessages#c4f40be as nil")
	}
	b.PutVectorHeader(len(d.RandomIDs))
	for _, v := range d.RandomIDs {
		b.PutLong(v)
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionReadMessages) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionReadMessages#c4f40be to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionReadMessagesTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionReadMessages#c4f40be: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionReadMessages) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionReadMessages#c4f40be to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionReadMessages#c4f40be: field random_ids: %w", err)
		}

		if headerLen > 0 {
			d.RandomIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode decryptedMessageActionReadMessages#c4f40be: field random_ids: %w", err)
			}
			d.RandomIDs = append(d.RandomIDs, value)
		}
	}
	return nil
}

// GetRandomIDs returns value of RandomIDs field.
func (d *DecryptedMessageActionReadMessages) GetRandomIDs() (value []int64) {
	if d == nil {
		return
	}
	return d.RandomIDs
}

// DecryptedMessageActionDeleteMessages represents TL type `decryptedMessageActionDeleteMessages#65614304`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionDeleteMessages for reference.
type DecryptedMessageActionDeleteMessages struct {
	// RandomIDs field of DecryptedMessageActionDeleteMessages.
	RandomIDs []int64
}

// DecryptedMessageActionDeleteMessagesTypeID is TL type id of DecryptedMessageActionDeleteMessages.
const DecryptedMessageActionDeleteMessagesTypeID = 0x65614304

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionDeleteMessages) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionDeleteMessages{}
)

func (d *DecryptedMessageActionDeleteMessages) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomIDs == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionDeleteMessages) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionDeleteMessages",
		ID:   DecryptedMessageActionDeleteMessagesTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomIDs",
			SchemaName: "random_ids",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionDeleteMessages) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionDeleteMessages#65614304 as nil")
	}
	b.PutID(DecryptedMessageActionDeleteMessagesTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionDeleteMessages) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionDeleteMessages#65614304 as nil")
	}
	b.PutVectorHeader(len(d.RandomIDs))
	for _, v := range d.RandomIDs {
		b.PutLong(v)
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionDeleteMessages) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionDeleteMessages#65614304 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionDeleteMessagesTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionDeleteMessages#65614304: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionDeleteMessages) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionDeleteMessages#65614304 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionDeleteMessages#65614304: field random_ids: %w", err)
		}

		if headerLen > 0 {
			d.RandomIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode decryptedMessageActionDeleteMessages#65614304: field random_ids: %w", err)
			}
			d.RandomIDs = append(d.RandomIDs, value)
		}
	}
	return nil
}

// GetRandomIDs returns value of RandomIDs field.
func (d *DecryptedMessageActionDeleteMessages) GetRandomIDs() (value []int64) {
	if d == nil {
		return
	}
	return d.RandomIDs
}

// DecryptedMessageActionScreenshotMessages represents TL type `decryptedMessageActionScreenshotMessages#8ac1f475`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionScreenshotMessages for reference.
type DecryptedMessageActionScreenshotMessages struct {
	// RandomIDs field of DecryptedMessageActionScreenshotMessages.
	RandomIDs []int64
}

// DecryptedMessageActionScreenshotMessagesTypeID is TL type id of DecryptedMessageActionScreenshotMessages.
const DecryptedMessageActionScreenshotMessagesTypeID = 0x8ac1f475

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionScreenshotMessages) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionScreenshotMessages{}
)

func (d *DecryptedMessageActionScreenshotMessages) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomIDs == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionScreenshotMessages) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionScreenshotMessages",
		ID:   DecryptedMessageActionScreenshotMessagesTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomIDs",
			SchemaName: "random_ids",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionScreenshotMessages) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionScreenshotMessages#8ac1f475 as nil")
	}
	b.PutID(DecryptedMessageActionScreenshotMessagesTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionScreenshotMessages) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionScreenshotMessages#8ac1f475 as nil")
	}
	b.PutVectorHeader(len(d.RandomIDs))
	for _, v := range d.RandomIDs {
		b.PutLong(v)
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionScreenshotMessages) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionScreenshotMessages#8ac1f475 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionScreenshotMessagesTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionScreenshotMessages#8ac1f475: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionScreenshotMessages) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionScreenshotMessages#8ac1f475 to nil")
	}
	{
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionScreenshotMessages#8ac1f475: field random_ids: %w", err)
		}

		if headerLen > 0 {
			d.RandomIDs = make([]int64, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode decryptedMessageActionScreenshotMessages#8ac1f475: field random_ids: %w", err)
			}
			d.RandomIDs = append(d.RandomIDs, value)
		}
	}
	return nil
}

// GetRandomIDs returns value of RandomIDs field.
func (d *DecryptedMessageActionScreenshotMessages) GetRandomIDs() (value []int64) {
	if d == nil {
		return
	}
	return d.RandomIDs
}

// DecryptedMessageActionFlushHistory represents TL type `decryptedMessageActionFlushHistory#6719e45c`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionFlushHistory for reference.
type DecryptedMessageActionFlushHistory struct {
}

// DecryptedMessageActionFlushHistoryTypeID is TL type id of DecryptedMessageActionFlushHistory.
const DecryptedMessageActionFlushHistoryTypeID = 0x6719e45c

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionFlushHistory) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionFlushHistory{}
)

func (d *DecryptedMessageActionFlushHistory) Zero() bool {
	if d == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionFlushHistory) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionFlushHistory#6719e45c as nil")
	}
	b.PutID(DecryptedMessageActionFlushHistoryTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionFlushHistory) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionFlushHistory#6719e45c as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionFlushHistory) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionFlushHistory#6719e45c to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionFlushHistoryTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionFlushHistory#6719e45c: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionFlushHistory) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionFlushHistory#6719e45c to nil")
	}
	return nil
}

// DecryptedMessageActionResend represents TL type `decryptedMessageActionResend#511110b0`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionResend for reference.
type DecryptedMessageActionResend struct {
	// StartSeqNo field of DecryptedMessageActionResend.
	StartSeqNo int
	// EndSeqNo field of DecryptedMessageActionResend.
	EndSeqNo int
}

// DecryptedMessageActionResendTypeID is TL type id of DecryptedMessageActionResend.
const DecryptedMessageActionResendTypeID = 0x511110b0

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionResend) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionResend{}
)

func (d *DecryptedMessageActionResend) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.StartSeqNo == 0) {
		return false
	}
	if !(d.EndSeqNo == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionResend) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionResend",
		ID:   DecryptedMessageActionResendTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "StartSeqNo",
			SchemaName: "start_seq_no",
		},
		{
			Name:       "EndSeqNo",
			SchemaName: "end_seq_no",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionResend) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionResend#511110b0 as nil")
	}
	b.PutID(DecryptedMessageActionResendTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionResend) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionResend#511110b0 as nil")
	}
	b.PutInt(d.StartSeqNo)
	b.PutInt(d.EndSeqNo)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionResend) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionResend#511110b0 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionResendTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionResend#511110b0: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionResend) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionResend#511110b0 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionResend#511110b0: field start_seq_no: %w", err)
		}
		d.StartSeqNo = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionResend#511110b0: field end_seq_no: %w", err)
		}
		d.EndSeqNo = value
	}
	return nil
}

// GetStartSeqNo returns value of StartSeqNo field.
func (d *DecryptedMessageActionResend) GetStartSeqNo() (value int) {
	if d == nil {
		return
	}
	return d.StartSeqNo
}

// GetEndSeqNo returns value of EndSeqNo field.
func (d *DecryptedMessageActionResend) GetEndSeqNo() (value int) {
	if d == nil {
		return
	}
	return d.EndSeqNo
}

// DecryptedMessageActionNotifyLayer represents TL type `decryptedMessageActionNotifyLayer#f3048883`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionNotifyLayer for reference.
type DecryptedMessageActionNotifyLayer struct {
	// Layer field of DecryptedMessageActionNotifyLayer.
	Layer int
}

// DecryptedMessageActionNotifyLayerTypeID is TL type id of DecryptedMessageActionNotifyLayer.
const DecryptedMessageActionNotifyLayerTypeID = 0xf3048883

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionNotifyLayer) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionNotifyLayer{}
)

func (d *DecryptedMessageActionNotifyLayer) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.Layer == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionNotifyLayer) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionNotifyLayer",
		ID:   DecryptedMessageActionNotifyLayerTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Layer",
			SchemaName: "layer",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionNotifyLayer) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionNotifyLayer#f3048883 as nil")
	}
	b.PutID(DecryptedMessageActionNotifyLayerTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionNotifyLayer) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionNotifyLayer#f3048883 as nil")
	}
	b.PutInt(d.Layer)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionNotifyLayer) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionNotifyLayer#f3048883 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionNotifyLayerTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionNotifyLayer#f3048883: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionNotifyLayer) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionNotifyLayer#f3048883 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionNotifyLayer#f3048883: field layer: %w", err)
		}
		d.Layer = value
	}
	return nil
}

// GetLayer returns value of Layer field.
func (d *DecryptedMessageActionNotifyLayer) GetLayer() (value int) {
	if d == nil {
		return
	}
	return d.Layer
}

// DecryptedMessageActionTyping represents TL type `decryptedMessageActionTyping#ccb27641`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionTyping for reference.
type DecryptedMessageActionTyping struct {
	// Action field of DecryptedMessageActionTyping.
	Action SendMessageActionClass
}

// DecryptedMessageActionTypingTypeID is TL type id of DecryptedMessageActionTyping.
const DecryptedMessageActionTypingTypeID = 0xccb27641

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionTyping) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionTyping{}
)

func (d *DecryptedMessageActionTyping) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.Action == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionTyping) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionTyping",
		ID:   DecryptedMessageActionTypingTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Action",
			SchemaName: "action",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionTyping) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionTyping#ccb27641 as nil")
	}
	b.PutID(DecryptedMessageActionTypingTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionTyping) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionTyping#ccb27641 as nil")
	}
	if d.Action == nil {
		return fmt.Errorf("unable to encode decryptedMessageActionTyping#ccb27641: field action is nil")
	}
	if err := d.Action.Encode(b); err != nil {
		return fmt.Errorf("unable to encode decryptedMessageActionTyping#ccb27641: field action: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionTyping) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionTyping#ccb27641 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionTypingTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionTyping#ccb27641: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionTyping) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionTyping#ccb27641 to nil")
	}
	{
		value, err := DecodeSendMessageAction(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionTyping#ccb27641: field action: %w", err)
		}
		d.Action = value
	}
	return nil
}

// GetAction returns value of Action field.
func (d *DecryptedMessageActionTyping) GetAction() (value SendMessageActionClass) {
	if d == nil {
		return
	}
	return d.Action
}

// DecryptedMessageActionRequestKey represents TL type `decryptedMessageActionRequestKey#f3c9611b`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionRequestKey for reference.
type DecryptedMessageActionRequestKey struct {
	// ExchangeID field of DecryptedMessageActionRequestKey.
	ExchangeID int64
	// GA field of DecryptedMessageActionRequestKey.
	GA []byte
}

// DecryptedMessageActionRequestKeyTypeID is TL type id of DecryptedMessageActionRequestKey.
const DecryptedMessageActionRequestKeyTypeID = 0xf3c9611b

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionRequestKey) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionRequestKey{}
)

func (d *DecryptedMessageActionRequestKey) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.ExchangeID == 0) {
		return false
	}
	if !(d.GA == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionRequestKey) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionRequestKey",
		ID:   DecryptedMessageActionRequestKeyTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ExchangeID",
			SchemaName: "exchange_id",
		},
		{
			Name:       "GA",
			SchemaName: "g_a",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionRequestKey) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionRequestKey#f3c9611b as nil")
	}
	b.PutID(DecryptedMessageActionRequestKeyTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionRequestKey) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionRequestKey#f3c9611b as nil")
	}
	b.PutLong(d.ExchangeID)
	b.PutBytes(d.GA)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionRequestKey) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionRequestKey#f3c9611b to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionRequestKeyTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionRequestKey#f3c9611b: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionRequestKey) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionRequestKey#f3c9611b to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionRequestKey#f3c9611b: field exchange_id: %w", err)
		}
		d.ExchangeID = value
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionRequestKey#f3c9611b: field g_a: %w", err)
		}
		d.GA = value
	}
	return nil
}

// GetExchangeID returns value of ExchangeID field.
func (d *DecryptedMessageActionRequestKey) GetExchangeID() (value int64) {
	if d == nil {
		return
	}
	return d.ExchangeID
}

// GetGA returns value of GA field.
func (d *DecryptedMessageActionRequestKey) GetGA() (value []byte) {
	if d == nil {
		return
	}
	return d.GA
}

// DecryptedMessageActionAcceptKey represents TL type `decryptedMessageActionAcceptKey#6fe1735b`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionAcceptKey for reference.
type DecryptedMessageActionAcceptKey struct {
	// ExchangeID field of DecryptedMessageActionAcceptKey.
	ExchangeID int64
	// GB field of DecryptedMessageActionAcceptKey.
	GB []byte
	// KeyFingerprint field of DecryptedMessageActionAcceptKey.
	KeyFingerprint int64
}

// DecryptedMessageActionAcceptKeyTypeID is TL type id of DecryptedMessageActionAcceptKey.
const DecryptedMessageActionAcceptKeyTypeID = 0x6fe1735b

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionAcceptKey) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionAcceptKey{}
)

func (d *DecryptedMessageActionAcceptKey) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.ExchangeID == 0) {
		return false
	}
	if !(d.GB == nil) {
		return false
	}
	if !(d.KeyFingerprint == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionAcceptKey) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionAcceptKey",
		ID:   DecryptedMessageActionAcceptKeyTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ExchangeID",
			SchemaName: "exchange_id",
		},
		{
			Name:       "GB",
			SchemaName: "g_b",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionAcceptKey) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionAcceptKey#6fe1735b as nil")
	}
	b.PutID(DecryptedMessageActionAcceptKeyTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionAcceptKey) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionAcceptKey#6fe1735b as nil")
	}
	b.PutLong(d.ExchangeID)
	b.PutBytes(d.GB)
	b.PutLong(d.KeyFingerprint)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionAcceptKey) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionAcceptKey#6fe1735b to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionAcceptKeyTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionAcceptKey#6fe1735b: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionAcceptKey) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionAcceptKey#6fe1735b to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionAcceptKey#6fe1735b: field exchange_id: %w", err)
		}
		d.ExchangeID = value
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionAcceptKey#6fe1735b: field g_b: %w", err)
		}
		d.GB = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionAcceptKey#6fe1735b: field key_fingerprint: %w", err)
		}
		d.KeyFingerprint = value
	}
	return nil
}

// GetExchangeID returns value of ExchangeID field.
func (d *DecryptedMessageActionAcceptKey) GetExchangeID() (value int64) {
	if d == nil {
		return
	}
	return d.ExchangeID
}

// GetGB returns value of GB field.
func (d *DecryptedMessageActionAcceptKey) GetGB() (value []byte) {
	if d == nil {
		return
	}
	return d.GB
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func (d *DecryptedMessageActionAcceptKey) GetKeyFingerprint() (value int64) {
	if d == nil {
		return
	}
	return d.KeyFingerprint
}

// DecryptedMessageActionAbortKey represents TL type `decryptedMessageActionAbortKey#dd05ec6b`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionAbortKey for reference.
type DecryptedMessageActionAbortKey struct {
	// ExchangeID field of DecryptedMessageActionAbortKey.
	ExchangeID int64
}

// DecryptedMessageActionAbortKeyTypeID is TL type id of DecryptedMessageActionAbortKey.
const DecryptedMessageActionAbortKeyTypeID = 0xdd05ec6b

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionAbortKey) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionAbortKey{}
)

func (d *DecryptedMessageActionAbortKey) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.ExchangeID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionAbortKey) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionAbortKey",
		ID:   DecryptedMessageActionAbortKeyTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ExchangeID",
			SchemaName: "exchange_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionAbortKey) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionAbortKey#dd05ec6b as nil")
	}
	b.PutID(DecryptedMessageActionAbortKeyTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionAbortKey) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionAbortKey#dd05ec6b as nil")
	}
	b.PutLong(d.ExchangeID)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionAbortKey) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionAbortKey#dd05ec6b to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionAbortKeyTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionAbortKey#dd05ec6b: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionAbortKey) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionAbortKey#dd05ec6b to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionAbortKey#dd05ec6b: field exchange_id: %w", err)
		}
		d.ExchangeID = value
	}
	return nil
}

// GetExchangeID returns value of ExchangeID field.
func (d *DecryptedMessageActionAbortKey) GetExchangeID() (value int64) {
	if d == nil {
		return
	}
	return d.ExchangeID
}

// DecryptedMessageActionCommitKey represents TL type `decryptedMessageActionCommitKey#ec2e0b9b`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionCommitKey for reference.
type DecryptedMessageActionCommitKey struct {
	// ExchangeID field of DecryptedMessageActionCommitKey.
	ExchangeID int64
	// KeyFingerprint field of DecryptedMessageActionCommitKey.
	KeyFingerprint int64
}

// DecryptedMessageActionCommitKeyTypeID is TL type id of DecryptedMessageActionCommitKey.
const DecryptedMessageActionCommitKeyTypeID = 0xec2e0b9b

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionCommitKey) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionCommitKey{}
)

func (d *DecryptedMessageActionCommitKey) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.ExchangeID == 0) {
		return false
	}
	if !(d.KeyFingerprint == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageActionCommitKey) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageActionCommitKey",
		ID:   DecryptedMessageActionCommitKeyTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ExchangeID",
			SchemaName: "exchange_id",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionCommitKey) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionCommitKey#ec2e0b9b as nil")
	}
	b.PutID(DecryptedMessageActionCommitKeyTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionCommitKey) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionCommitKey#ec2e0b9b as nil")
	}
	b.PutLong(d.ExchangeID)
	b.PutLong(d.KeyFingerprint)
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionCommitKey) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionCommitKey#ec2e0b9b to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionCommitKeyTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionCommitKey#ec2e0b9b: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionCommitKey) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionCommitKey#ec2e0b9b to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionCommitKey#ec2e0b9b: field exchange_id: %w", err)
		}
		d.ExchangeID = value
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageActionCommitKey#ec2e0b9b: field key_fingerprint: %w", err)
		}
		d.KeyFingerprint = value
	}
	return nil
}

// GetExchangeID returns value of ExchangeID field.
func (d *DecryptedMessageActionCommitKey) GetExchangeID() (value int64) {
	if d == nil {
		return
	}
	return d.ExchangeID
}

// GetKeyFingerprint returns value of KeyFingerprint field.
func (d *DecryptedMessageActionCommitKey) GetKeyFingerprint() (value int64) {
	if d == nil {
		return
	}
	return d.KeyFingerprint
}

// DecryptedMessageActionNoop represents TL type `decryptedMessageActionNoop#a82fdd63`.
//
// See https://core.telegram.org/constructor/decryptedMessageActionNoop for reference.
type DecryptedMessageActionNoop struct {
}

// DecryptedMessageActionNoopTypeID is TL type id of DecryptedMessageActionNoop.
const DecryptedMessageActionNoopTypeID = 0xa82fdd63

// construct implements constructor of DecryptedMessageActionClass.
func (d DecryptedMessageActionNoop) construct() DecryptedMessageActionClass { return &d }

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

	_ DecryptedMessageActionClass = &DecryptedMessageActionNoop{}
)

func (d *DecryptedMessageActionNoop) Zero() bool {
	if d == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (d *DecryptedMessageActionNoop) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionNoop#a82fdd63 as nil")
	}
	b.PutID(DecryptedMessageActionNoopTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessageActionNoop) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageActionNoop#a82fdd63 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (d *DecryptedMessageActionNoop) Decode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionNoop#a82fdd63 to nil")
	}
	if err := b.ConsumeID(DecryptedMessageActionNoopTypeID); err != nil {
		return fmt.Errorf("unable to decode decryptedMessageActionNoop#a82fdd63: %w", err)
	}
	return d.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageActionNoop) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageActionNoop#a82fdd63 to nil")
	}
	return nil
}

// DecryptedMessageActionClassName is schema name of DecryptedMessageActionClass.
const DecryptedMessageActionClassName = "DecryptedMessageAction"

// DecryptedMessageActionClass represents DecryptedMessageAction generic type.
//
// See https://core.telegram.org/type/DecryptedMessageAction for reference.
//
// Example:
//
//	g, err := e2e.DecodeDecryptedMessageAction(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *e2e.DecryptedMessageActionSetMessageTTL: // decryptedMessageActionSetMessageTTL#a1733aec
//	case *e2e.DecryptedMessageActionReadMessages: // decryptedMessageActionReadMessages#c4f40be
//	case *e2e.DecryptedMessageActionDeleteMessages: // decryptedMessageActionDeleteMessages#65614304
//	case *e2e.DecryptedMessageActionScreenshotMessages: // decryptedMessageActionScreenshotMessages#8ac1f475
//	case *e2e.DecryptedMessageActionFlushHistory: // decryptedMessageActionFlushHistory#6719e45c
//	case *e2e.DecryptedMessageActionResend: // decryptedMessageActionResend#511110b0
//	case *e2e.DecryptedMessageActionNotifyLayer: // decryptedMessageActionNotifyLayer#f3048883
//	case *e2e.DecryptedMessageActionTyping: // decryptedMessageActionTyping#ccb27641
//	case *e2e.DecryptedMessageActionRequestKey: // decryptedMessageActionRequestKey#f3c9611b
//	case *e2e.DecryptedMessageActionAcceptKey: // decryptedMessageActionAcceptKey#6fe1735b
//	case *e2e.DecryptedMessageActionAbortKey: // decryptedMessageActionAbortKey#dd05ec6b
//	case *e2e.DecryptedMessageActionCommitKey: // decryptedMessageActionCommitKey#ec2e0b9b
//	case *e2e.DecryptedMessageActionNoop: // decryptedMessageActionNoop#a82fdd63
//	default: panic(v)
//	}
type DecryptedMessageActionClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DecryptedMessageActionClass

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

// DecodeDecryptedMessageAction implements binary de-serialization for DecryptedMessageActionClass.
func DecodeDecryptedMessageAction(buf *bin.Buffer) (DecryptedMessageActionClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case DecryptedMessageActionSetMessageTTLTypeID:
		// Decoding decryptedMessageActionSetMessageTTL#a1733aec.
		v := DecryptedMessageActionSetMessageTTL{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionReadMessagesTypeID:
		// Decoding decryptedMessageActionReadMessages#c4f40be.
		v := DecryptedMessageActionReadMessages{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionDeleteMessagesTypeID:
		// Decoding decryptedMessageActionDeleteMessages#65614304.
		v := DecryptedMessageActionDeleteMessages{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionScreenshotMessagesTypeID:
		// Decoding decryptedMessageActionScreenshotMessages#8ac1f475.
		v := DecryptedMessageActionScreenshotMessages{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionFlushHistoryTypeID:
		// Decoding decryptedMessageActionFlushHistory#6719e45c.
		v := DecryptedMessageActionFlushHistory{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionResendTypeID:
		// Decoding decryptedMessageActionResend#511110b0.
		v := DecryptedMessageActionResend{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionNotifyLayerTypeID:
		// Decoding decryptedMessageActionNotifyLayer#f3048883.
		v := DecryptedMessageActionNotifyLayer{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionTypingTypeID:
		// Decoding decryptedMessageActionTyping#ccb27641.
		v := DecryptedMessageActionTyping{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionRequestKeyTypeID:
		// Decoding decryptedMessageActionRequestKey#f3c9611b.
		v := DecryptedMessageActionRequestKey{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionAcceptKeyTypeID:
		// Decoding decryptedMessageActionAcceptKey#6fe1735b.
		v := DecryptedMessageActionAcceptKey{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionAbortKeyTypeID:
		// Decoding decryptedMessageActionAbortKey#dd05ec6b.
		v := DecryptedMessageActionAbortKey{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionCommitKeyTypeID:
		// Decoding decryptedMessageActionCommitKey#ec2e0b9b.
		v := DecryptedMessageActionCommitKey{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageActionNoopTypeID:
		// Decoding decryptedMessageActionNoop#a82fdd63.
		v := DecryptedMessageActionNoop{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode DecryptedMessageActionClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecryptedMessageAction boxes the DecryptedMessageActionClass providing a helper.
type DecryptedMessageActionBox struct {
	DecryptedMessageAction DecryptedMessageActionClass
}

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

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