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

// DecryptedMessage8 represents TL type `decryptedMessage8#1f814f1f`.
//
// See https://core.telegram.org/constructor/decryptedMessage8 for reference.
type DecryptedMessage8 struct {
	// RandomID field of DecryptedMessage8.
	RandomID int64
	// RandomBytes field of DecryptedMessage8.
	RandomBytes []byte
	// Message field of DecryptedMessage8.
	Message string
	// Media field of DecryptedMessage8.
	Media DecryptedMessageMediaClass
}

// DecryptedMessage8TypeID is TL type id of DecryptedMessage8.
const DecryptedMessage8TypeID = 0x1f814f1f

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessage8) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessage8{}
)

func (d *DecryptedMessage8) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomID == 0) {
		return false
	}
	if !(d.RandomBytes == nil) {
		return false
	}
	if !(d.Message == "") {
		return false
	}
	if !(d.Media == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessage8) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessage8",
		ID:   DecryptedMessage8TypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "RandomBytes",
			SchemaName: "random_bytes",
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessage8) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage8#1f814f1f as nil")
	}
	b.PutID(DecryptedMessage8TypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessage8) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage8#1f814f1f as nil")
	}
	b.PutLong(d.RandomID)
	b.PutBytes(d.RandomBytes)
	b.PutString(d.Message)
	if d.Media == nil {
		return fmt.Errorf("unable to encode decryptedMessage8#1f814f1f: field media is nil")
	}
	if err := d.Media.Encode(b); err != nil {
		return fmt.Errorf("unable to encode decryptedMessage8#1f814f1f: field media: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessage8) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessage8#1f814f1f to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage8#1f814f1f: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage8#1f814f1f: field random_bytes: %w", err)
		}
		d.RandomBytes = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage8#1f814f1f: field message: %w", err)
		}
		d.Message = value
	}
	{
		value, err := DecodeDecryptedMessageMedia(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage8#1f814f1f: field media: %w", err)
		}
		d.Media = value
	}
	return nil
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessage8) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

// GetRandomBytes returns value of RandomBytes field.
func (d *DecryptedMessage8) GetRandomBytes() (value []byte) {
	if d == nil {
		return
	}
	return d.RandomBytes
}

// GetMessage returns value of Message field.
func (d *DecryptedMessage8) GetMessage() (value string) {
	if d == nil {
		return
	}
	return d.Message
}

// GetMedia returns value of Media field.
func (d *DecryptedMessage8) GetMedia() (value DecryptedMessageMediaClass) {
	if d == nil {
		return
	}
	return d.Media
}

// DecryptedMessageService8 represents TL type `decryptedMessageService8#aa48327d`.
//
// See https://core.telegram.org/constructor/decryptedMessageService8 for reference.
type DecryptedMessageService8 struct {
	// RandomID field of DecryptedMessageService8.
	RandomID int64
	// RandomBytes field of DecryptedMessageService8.
	RandomBytes []byte
	// Action field of DecryptedMessageService8.
	Action DecryptedMessageActionClass
}

// DecryptedMessageService8TypeID is TL type id of DecryptedMessageService8.
const DecryptedMessageService8TypeID = 0xaa48327d

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessageService8) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessageService8{}
)

func (d *DecryptedMessageService8) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomID == 0) {
		return false
	}
	if !(d.RandomBytes == nil) {
		return false
	}
	if !(d.Action == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessageService8) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessageService8",
		ID:   DecryptedMessageService8TypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "RandomBytes",
			SchemaName: "random_bytes",
		},
		{
			Name:       "Action",
			SchemaName: "action",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessageService8) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageService8#aa48327d as nil")
	}
	b.PutID(DecryptedMessageService8TypeID)
	return d.EncodeBare(b)
}

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

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageService8) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageService8#aa48327d to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageService8#aa48327d: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := b.Bytes()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageService8#aa48327d: field random_bytes: %w", err)
		}
		d.RandomBytes = value
	}
	{
		value, err := DecodeDecryptedMessageAction(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageService8#aa48327d: field action: %w", err)
		}
		d.Action = value
	}
	return nil
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessageService8) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

// GetRandomBytes returns value of RandomBytes field.
func (d *DecryptedMessageService8) GetRandomBytes() (value []byte) {
	if d == nil {
		return
	}
	return d.RandomBytes
}

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

// DecryptedMessage23 represents TL type `decryptedMessage23#204d3878`.
//
// See https://core.telegram.org/constructor/decryptedMessage23 for reference.
type DecryptedMessage23 struct {
	// RandomID field of DecryptedMessage23.
	RandomID int64
	// TTL field of DecryptedMessage23.
	TTL int
	// Message field of DecryptedMessage23.
	Message string
	// Media field of DecryptedMessage23.
	Media DecryptedMessageMediaClass
}

// DecryptedMessage23TypeID is TL type id of DecryptedMessage23.
const DecryptedMessage23TypeID = 0x204d3878

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessage23) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessage23{}
)

func (d *DecryptedMessage23) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.RandomID == 0) {
		return false
	}
	if !(d.TTL == 0) {
		return false
	}
	if !(d.Message == "") {
		return false
	}
	if !(d.Media == nil) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessage23) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessage23",
		ID:   DecryptedMessage23TypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "TTL",
			SchemaName: "ttl",
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (d *DecryptedMessage23) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage23#204d3878 as nil")
	}
	b.PutID(DecryptedMessage23TypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessage23) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage23#204d3878 as nil")
	}
	b.PutLong(d.RandomID)
	b.PutInt(d.TTL)
	b.PutString(d.Message)
	if d.Media == nil {
		return fmt.Errorf("unable to encode decryptedMessage23#204d3878: field media is nil")
	}
	if err := d.Media.Encode(b); err != nil {
		return fmt.Errorf("unable to encode decryptedMessage23#204d3878: field media: %w", err)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessage23) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessage23#204d3878 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage23#204d3878: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage23#204d3878: field ttl: %w", err)
		}
		d.TTL = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage23#204d3878: field message: %w", err)
		}
		d.Message = value
	}
	{
		value, err := DecodeDecryptedMessageMedia(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage23#204d3878: field media: %w", err)
		}
		d.Media = value
	}
	return nil
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessage23) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

// GetTTL returns value of TTL field.
func (d *DecryptedMessage23) GetTTL() (value int) {
	if d == nil {
		return
	}
	return d.TTL
}

// GetMessage returns value of Message field.
func (d *DecryptedMessage23) GetMessage() (value string) {
	if d == nil {
		return
	}
	return d.Message
}

// GetMedia returns value of Media field.
func (d *DecryptedMessage23) GetMedia() (value DecryptedMessageMediaClass) {
	if d == nil {
		return
	}
	return d.Media
}

// DecryptedMessageService represents TL type `decryptedMessageService#73164160`.
//
// See https://core.telegram.org/constructor/decryptedMessageService for reference.
type DecryptedMessageService struct {
	// RandomID field of DecryptedMessageService.
	RandomID int64
	// Action field of DecryptedMessageService.
	Action DecryptedMessageActionClass
}

// DecryptedMessageServiceTypeID is TL type id of DecryptedMessageService.
const DecryptedMessageServiceTypeID = 0x73164160

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessageService) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessageService{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (d *DecryptedMessageService) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessageService#73164160 as nil")
	}
	b.PutID(DecryptedMessageServiceTypeID)
	return d.EncodeBare(b)
}

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

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessageService) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessageService#73164160 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageService#73164160: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := DecodeDecryptedMessageAction(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessageService#73164160: field action: %w", err)
		}
		d.Action = value
	}
	return nil
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessageService) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

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

// DecryptedMessage46 represents TL type `decryptedMessage46#36b091de`.
//
// See https://core.telegram.org/constructor/decryptedMessage46 for reference.
type DecryptedMessage46 struct {
	// Flags field of DecryptedMessage46.
	Flags bin.Fields
	// RandomID field of DecryptedMessage46.
	RandomID int64
	// TTL field of DecryptedMessage46.
	TTL int
	// Message field of DecryptedMessage46.
	Message string
	// Media field of DecryptedMessage46.
	//
	// Use SetMedia and GetMedia helpers.
	Media DecryptedMessageMediaClass
	// Entities field of DecryptedMessage46.
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// ViaBotName field of DecryptedMessage46.
	//
	// Use SetViaBotName and GetViaBotName helpers.
	ViaBotName string
	// ReplyToRandomID field of DecryptedMessage46.
	//
	// Use SetReplyToRandomID and GetReplyToRandomID helpers.
	ReplyToRandomID int64
}

// DecryptedMessage46TypeID is TL type id of DecryptedMessage46.
const DecryptedMessage46TypeID = 0x36b091de

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessage46) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessage46{}
)

func (d *DecryptedMessage46) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.Flags.Zero()) {
		return false
	}
	if !(d.RandomID == 0) {
		return false
	}
	if !(d.TTL == 0) {
		return false
	}
	if !(d.Message == "") {
		return false
	}
	if !(d.Media == nil) {
		return false
	}
	if !(d.Entities == nil) {
		return false
	}
	if !(d.ViaBotName == "") {
		return false
	}
	if !(d.ReplyToRandomID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessage46) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessage46",
		ID:   DecryptedMessage46TypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "TTL",
			SchemaName: "ttl",
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Media",
			SchemaName: "media",
			Null:       !d.Flags.Has(9),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !d.Flags.Has(7),
		},
		{
			Name:       "ViaBotName",
			SchemaName: "via_bot_name",
			Null:       !d.Flags.Has(11),
		},
		{
			Name:       "ReplyToRandomID",
			SchemaName: "reply_to_random_id",
			Null:       !d.Flags.Has(3),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (d *DecryptedMessage46) SetFlags() {
	if !(d.Media == nil) {
		d.Flags.Set(9)
	}
	if !(d.Entities == nil) {
		d.Flags.Set(7)
	}
	if !(d.ViaBotName == "") {
		d.Flags.Set(11)
	}
	if !(d.ReplyToRandomID == 0) {
		d.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func (d *DecryptedMessage46) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage46#36b091de as nil")
	}
	b.PutID(DecryptedMessage46TypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessage46) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage46#36b091de as nil")
	}
	d.SetFlags()
	if err := d.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode decryptedMessage46#36b091de: field flags: %w", err)
	}
	b.PutLong(d.RandomID)
	b.PutInt(d.TTL)
	b.PutString(d.Message)
	if d.Flags.Has(9) {
		if d.Media == nil {
			return fmt.Errorf("unable to encode decryptedMessage46#36b091de: field media is nil")
		}
		if err := d.Media.Encode(b); err != nil {
			return fmt.Errorf("unable to encode decryptedMessage46#36b091de: field media: %w", err)
		}
	}
	if d.Flags.Has(7) {
		b.PutVectorHeader(len(d.Entities))
		for idx, v := range d.Entities {
			if v == nil {
				return fmt.Errorf("unable to encode decryptedMessage46#36b091de: field entities element with index %d is nil", idx)
			}
			if err := v.Encode(b); err != nil {
				return fmt.Errorf("unable to encode decryptedMessage46#36b091de: field entities element with index %d: %w", idx, err)
			}
		}
	}
	if d.Flags.Has(11) {
		b.PutString(d.ViaBotName)
	}
	if d.Flags.Has(3) {
		b.PutLong(d.ReplyToRandomID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessage46) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessage46#36b091de to nil")
	}
	{
		if err := d.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field flags: %w", err)
		}
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field ttl: %w", err)
		}
		d.TTL = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field message: %w", err)
		}
		d.Message = value
	}
	if d.Flags.Has(9) {
		value, err := DecodeDecryptedMessageMedia(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field media: %w", err)
		}
		d.Media = value
	}
	if d.Flags.Has(7) {
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field entities: %w", err)
		}

		if headerLen > 0 {
			d.Entities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodeMessageEntity(b)
			if err != nil {
				return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field entities: %w", err)
			}
			d.Entities = append(d.Entities, value)
		}
	}
	if d.Flags.Has(11) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field via_bot_name: %w", err)
		}
		d.ViaBotName = value
	}
	if d.Flags.Has(3) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage46#36b091de: field reply_to_random_id: %w", err)
		}
		d.ReplyToRandomID = value
	}
	return nil
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessage46) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

// GetTTL returns value of TTL field.
func (d *DecryptedMessage46) GetTTL() (value int) {
	if d == nil {
		return
	}
	return d.TTL
}

// GetMessage returns value of Message field.
func (d *DecryptedMessage46) GetMessage() (value string) {
	if d == nil {
		return
	}
	return d.Message
}

// SetMedia sets value of Media conditional field.
func (d *DecryptedMessage46) SetMedia(value DecryptedMessageMediaClass) {
	d.Flags.Set(9)
	d.Media = value
}

// GetMedia returns value of Media conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage46) GetMedia() (value DecryptedMessageMediaClass, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(9) {
		return value, false
	}
	return d.Media, true
}

// SetEntities sets value of Entities conditional field.
func (d *DecryptedMessage46) SetEntities(value []MessageEntityClass) {
	d.Flags.Set(7)
	d.Entities = value
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage46) GetEntities() (value []MessageEntityClass, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(7) {
		return value, false
	}
	return d.Entities, true
}

// SetViaBotName sets value of ViaBotName conditional field.
func (d *DecryptedMessage46) SetViaBotName(value string) {
	d.Flags.Set(11)
	d.ViaBotName = value
}

// GetViaBotName returns value of ViaBotName conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage46) GetViaBotName() (value string, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(11) {
		return value, false
	}
	return d.ViaBotName, true
}

// SetReplyToRandomID sets value of ReplyToRandomID conditional field.
func (d *DecryptedMessage46) SetReplyToRandomID(value int64) {
	d.Flags.Set(3)
	d.ReplyToRandomID = value
}

// GetReplyToRandomID returns value of ReplyToRandomID conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage46) GetReplyToRandomID() (value int64, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(3) {
		return value, false
	}
	return d.ReplyToRandomID, true
}

// DecryptedMessage represents TL type `decryptedMessage#91cc4674`.
//
// See https://core.telegram.org/constructor/decryptedMessage for reference.
type DecryptedMessage struct {
	// Flags field of DecryptedMessage.
	Flags bin.Fields
	// Silent field of DecryptedMessage.
	Silent bool
	// RandomID field of DecryptedMessage.
	RandomID int64
	// TTL field of DecryptedMessage.
	TTL int
	// Message field of DecryptedMessage.
	Message string
	// Media field of DecryptedMessage.
	//
	// Use SetMedia and GetMedia helpers.
	Media DecryptedMessageMediaClass
	// Entities field of DecryptedMessage.
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// ViaBotName field of DecryptedMessage.
	//
	// Use SetViaBotName and GetViaBotName helpers.
	ViaBotName string
	// ReplyToRandomID field of DecryptedMessage.
	//
	// Use SetReplyToRandomID and GetReplyToRandomID helpers.
	ReplyToRandomID int64
	// GroupedID field of DecryptedMessage.
	//
	// Use SetGroupedID and GetGroupedID helpers.
	GroupedID int64
}

// DecryptedMessageTypeID is TL type id of DecryptedMessage.
const DecryptedMessageTypeID = 0x91cc4674

// construct implements constructor of DecryptedMessageClass.
func (d DecryptedMessage) construct() DecryptedMessageClass { return &d }

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

	_ DecryptedMessageClass = &DecryptedMessage{}
)

func (d *DecryptedMessage) Zero() bool {
	if d == nil {
		return true
	}
	if !(d.Flags.Zero()) {
		return false
	}
	if !(d.Silent == false) {
		return false
	}
	if !(d.RandomID == 0) {
		return false
	}
	if !(d.TTL == 0) {
		return false
	}
	if !(d.Message == "") {
		return false
	}
	if !(d.Media == nil) {
		return false
	}
	if !(d.Entities == nil) {
		return false
	}
	if !(d.ViaBotName == "") {
		return false
	}
	if !(d.ReplyToRandomID == 0) {
		return false
	}
	if !(d.GroupedID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (d *DecryptedMessage) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "decryptedMessage",
		ID:   DecryptedMessageTypeID,
	}
	if d == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !d.Flags.Has(5),
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "TTL",
			SchemaName: "ttl",
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Media",
			SchemaName: "media",
			Null:       !d.Flags.Has(9),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !d.Flags.Has(7),
		},
		{
			Name:       "ViaBotName",
			SchemaName: "via_bot_name",
			Null:       !d.Flags.Has(11),
		},
		{
			Name:       "ReplyToRandomID",
			SchemaName: "reply_to_random_id",
			Null:       !d.Flags.Has(3),
		},
		{
			Name:       "GroupedID",
			SchemaName: "grouped_id",
			Null:       !d.Flags.Has(17),
		},
	}
	return typ
}

// SetFlags sets flags for non-zero fields.
func (d *DecryptedMessage) SetFlags() {
	if !(d.Silent == false) {
		d.Flags.Set(5)
	}
	if !(d.Media == nil) {
		d.Flags.Set(9)
	}
	if !(d.Entities == nil) {
		d.Flags.Set(7)
	}
	if !(d.ViaBotName == "") {
		d.Flags.Set(11)
	}
	if !(d.ReplyToRandomID == 0) {
		d.Flags.Set(3)
	}
	if !(d.GroupedID == 0) {
		d.Flags.Set(17)
	}
}

// Encode implements bin.Encoder.
func (d *DecryptedMessage) Encode(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage#91cc4674 as nil")
	}
	b.PutID(DecryptedMessageTypeID)
	return d.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (d *DecryptedMessage) EncodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't encode decryptedMessage#91cc4674 as nil")
	}
	d.SetFlags()
	if err := d.Flags.Encode(b); err != nil {
		return fmt.Errorf("unable to encode decryptedMessage#91cc4674: field flags: %w", err)
	}
	b.PutLong(d.RandomID)
	b.PutInt(d.TTL)
	b.PutString(d.Message)
	if d.Flags.Has(9) {
		if d.Media == nil {
			return fmt.Errorf("unable to encode decryptedMessage#91cc4674: field media is nil")
		}
		if err := d.Media.Encode(b); err != nil {
			return fmt.Errorf("unable to encode decryptedMessage#91cc4674: field media: %w", err)
		}
	}
	if d.Flags.Has(7) {
		b.PutVectorHeader(len(d.Entities))
		for idx, v := range d.Entities {
			if v == nil {
				return fmt.Errorf("unable to encode decryptedMessage#91cc4674: field entities element with index %d is nil", idx)
			}
			if err := v.Encode(b); err != nil {
				return fmt.Errorf("unable to encode decryptedMessage#91cc4674: field entities element with index %d: %w", idx, err)
			}
		}
	}
	if d.Flags.Has(11) {
		b.PutString(d.ViaBotName)
	}
	if d.Flags.Has(3) {
		b.PutLong(d.ReplyToRandomID)
	}
	if d.Flags.Has(17) {
		b.PutLong(d.GroupedID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func (d *DecryptedMessage) DecodeBare(b *bin.Buffer) error {
	if d == nil {
		return fmt.Errorf("can't decode decryptedMessage#91cc4674 to nil")
	}
	{
		if err := d.Flags.Decode(b); err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field flags: %w", err)
		}
	}
	d.Silent = d.Flags.Has(5)
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field random_id: %w", err)
		}
		d.RandomID = value
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field ttl: %w", err)
		}
		d.TTL = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field message: %w", err)
		}
		d.Message = value
	}
	if d.Flags.Has(9) {
		value, err := DecodeDecryptedMessageMedia(b)
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field media: %w", err)
		}
		d.Media = value
	}
	if d.Flags.Has(7) {
		headerLen, err := b.VectorHeader()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field entities: %w", err)
		}

		if headerLen > 0 {
			d.Entities = make([]MessageEntityClass, 0, headerLen%bin.PreallocateLimit)
		}
		for idx := 0; idx < headerLen; idx++ {
			value, err := DecodeMessageEntity(b)
			if err != nil {
				return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field entities: %w", err)
			}
			d.Entities = append(d.Entities, value)
		}
	}
	if d.Flags.Has(11) {
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field via_bot_name: %w", err)
		}
		d.ViaBotName = value
	}
	if d.Flags.Has(3) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field reply_to_random_id: %w", err)
		}
		d.ReplyToRandomID = value
	}
	if d.Flags.Has(17) {
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode decryptedMessage#91cc4674: field grouped_id: %w", err)
		}
		d.GroupedID = value
	}
	return nil
}

// SetSilent sets value of Silent conditional field.
func (d *DecryptedMessage) SetSilent(value bool) {
	if value {
		d.Flags.Set(5)
		d.Silent = true
	} else {
		d.Flags.Unset(5)
		d.Silent = false
	}
}

// GetSilent returns value of Silent conditional field.
func (d *DecryptedMessage) GetSilent() (value bool) {
	if d == nil {
		return
	}
	return d.Flags.Has(5)
}

// GetRandomID returns value of RandomID field.
func (d *DecryptedMessage) GetRandomID() (value int64) {
	if d == nil {
		return
	}
	return d.RandomID
}

// GetTTL returns value of TTL field.
func (d *DecryptedMessage) GetTTL() (value int) {
	if d == nil {
		return
	}
	return d.TTL
}

// GetMessage returns value of Message field.
func (d *DecryptedMessage) GetMessage() (value string) {
	if d == nil {
		return
	}
	return d.Message
}

// SetMedia sets value of Media conditional field.
func (d *DecryptedMessage) SetMedia(value DecryptedMessageMediaClass) {
	d.Flags.Set(9)
	d.Media = value
}

// GetMedia returns value of Media conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage) GetMedia() (value DecryptedMessageMediaClass, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(9) {
		return value, false
	}
	return d.Media, true
}

// SetEntities sets value of Entities conditional field.
func (d *DecryptedMessage) SetEntities(value []MessageEntityClass) {
	d.Flags.Set(7)
	d.Entities = value
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage) GetEntities() (value []MessageEntityClass, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(7) {
		return value, false
	}
	return d.Entities, true
}

// SetViaBotName sets value of ViaBotName conditional field.
func (d *DecryptedMessage) SetViaBotName(value string) {
	d.Flags.Set(11)
	d.ViaBotName = value
}

// GetViaBotName returns value of ViaBotName conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage) GetViaBotName() (value string, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(11) {
		return value, false
	}
	return d.ViaBotName, true
}

// SetReplyToRandomID sets value of ReplyToRandomID conditional field.
func (d *DecryptedMessage) SetReplyToRandomID(value int64) {
	d.Flags.Set(3)
	d.ReplyToRandomID = value
}

// GetReplyToRandomID returns value of ReplyToRandomID conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage) GetReplyToRandomID() (value int64, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(3) {
		return value, false
	}
	return d.ReplyToRandomID, true
}

// SetGroupedID sets value of GroupedID conditional field.
func (d *DecryptedMessage) SetGroupedID(value int64) {
	d.Flags.Set(17)
	d.GroupedID = value
}

// GetGroupedID returns value of GroupedID conditional field and
// boolean which is true if field was set.
func (d *DecryptedMessage) GetGroupedID() (value int64, ok bool) {
	if d == nil {
		return
	}
	if !d.Flags.Has(17) {
		return value, false
	}
	return d.GroupedID, true
}

// DecryptedMessageClassName is schema name of DecryptedMessageClass.
const DecryptedMessageClassName = "DecryptedMessage"

// DecryptedMessageClass represents DecryptedMessage generic type.
//
// See https://core.telegram.org/type/DecryptedMessage for reference.
//
// Example:
//
//	g, err := e2e.DecodeDecryptedMessage(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *e2e.DecryptedMessage8: // decryptedMessage8#1f814f1f
//	case *e2e.DecryptedMessageService8: // decryptedMessageService8#aa48327d
//	case *e2e.DecryptedMessage23: // decryptedMessage23#204d3878
//	case *e2e.DecryptedMessageService: // decryptedMessageService#73164160
//	case *e2e.DecryptedMessage46: // decryptedMessage46#36b091de
//	case *e2e.DecryptedMessage: // decryptedMessage#91cc4674
//	default: panic(v)
//	}
type DecryptedMessageClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DecryptedMessageClass

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

	// RandomID field of DecryptedMessage8.
	GetRandomID() (value int64)
}

// DecodeDecryptedMessage implements binary de-serialization for DecryptedMessageClass.
func DecodeDecryptedMessage(buf *bin.Buffer) (DecryptedMessageClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case DecryptedMessage8TypeID:
		// Decoding decryptedMessage8#1f814f1f.
		v := DecryptedMessage8{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageService8TypeID:
		// Decoding decryptedMessageService8#aa48327d.
		v := DecryptedMessageService8{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	case DecryptedMessage23TypeID:
		// Decoding decryptedMessage23#204d3878.
		v := DecryptedMessage23{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageServiceTypeID:
		// Decoding decryptedMessageService#73164160.
		v := DecryptedMessageService{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	case DecryptedMessage46TypeID:
		// Decoding decryptedMessage46#36b091de.
		v := DecryptedMessage46{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	case DecryptedMessageTypeID:
		// Decoding decryptedMessage#91cc4674.
		v := DecryptedMessage{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode DecryptedMessageClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecryptedMessage boxes the DecryptedMessageClass providing a helper.
type DecryptedMessageBox struct {
	DecryptedMessage DecryptedMessageClass
}

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

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