// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// EncryptedChatEmpty represents TL type `encryptedChatEmpty#ab7ec0a0`.
// Empty constructor.
//
// See https://core.telegram.org/constructor/encryptedChatEmpty for reference.
type EncryptedChatEmpty struct {
	// Chat ID
	ID int
}

// EncryptedChatEmptyTypeID is TL type id of EncryptedChatEmpty.
const EncryptedChatEmptyTypeID = 0xab7ec0a0

// construct implements constructor of EncryptedChatClass.
func ( EncryptedChatEmpty) () EncryptedChatClass { return & }

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

	_ EncryptedChatClass = &EncryptedChatEmpty{}
)

func ( *EncryptedChatEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedChatEmpty from given interface.
func ( *EncryptedChatEmpty) ( interface {
	() ( int)
}) {
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedChatEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedChatEmpty",
		ID:   EncryptedChatEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EncryptedChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatEmpty#ab7ec0a0 as nil")
	}
	.PutID(EncryptedChatEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatEmpty#ab7ec0a0 as nil")
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedChatEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedChatEmpty#ab7ec0a0 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatEmpty#ab7ec0a0: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *EncryptedChatEmpty) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// EncryptedChatWaiting represents TL type `encryptedChatWaiting#66b25953`.
// Chat waiting for approval of second participant.
//
// See https://core.telegram.org/constructor/encryptedChatWaiting for reference.
type EncryptedChatWaiting struct {
	// Chat ID
	ID int
	// Checking sum depending on user ID
	AccessHash int64
	// Date of chat creation
	Date int
	// Chat creator ID
	AdminID int64
	// ID of second chat participant
	ParticipantID int64
}

// EncryptedChatWaitingTypeID is TL type id of EncryptedChatWaiting.
const EncryptedChatWaitingTypeID = 0x66b25953

// construct implements constructor of EncryptedChatClass.
func ( EncryptedChatWaiting) () EncryptedChatClass { return & }

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

	_ EncryptedChatClass = &EncryptedChatWaiting{}
)

func ( *EncryptedChatWaiting) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedChatWaiting from given interface.
func ( *EncryptedChatWaiting) ( interface {
	() ( int)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
}) {
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedChatWaiting) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedChatWaiting",
		ID:   EncryptedChatWaitingTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EncryptedChatWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatWaiting#66b25953 as nil")
	}
	.PutID(EncryptedChatWaitingTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedChatWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatWaiting#66b25953 as nil")
	}
	.PutInt(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedChatWaiting) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedChatWaiting#66b25953 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatWaiting#66b25953: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatWaiting#66b25953: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatWaiting#66b25953: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatWaiting#66b25953: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatWaiting#66b25953: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *EncryptedChatWaiting) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *EncryptedChatWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *EncryptedChatWaiting) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *EncryptedChatWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *EncryptedChatWaiting) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// EncryptedChatRequested represents TL type `encryptedChatRequested#48f1d94c`.
// Request to create an encrypted chat.
//
// See https://core.telegram.org/constructor/encryptedChatRequested for reference.
type EncryptedChatRequested struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Peer folder ID, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	//
	// Use SetFolderID and GetFolderID helpers.
	FolderID int
	// Chat ID
	ID int
	// Check sum depending on user ID
	AccessHash int64
	// Chat creation date
	Date int
	// Chat creator ID
	AdminID int64
	// ID of second chat participant
	ParticipantID int64
	// A = g ^ a mod p, see Wikipedia¹
	//
	// Links:
	//  1) https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
	GA []byte
}

// EncryptedChatRequestedTypeID is TL type id of EncryptedChatRequested.
const EncryptedChatRequestedTypeID = 0x48f1d94c

// construct implements constructor of EncryptedChatClass.
func ( EncryptedChatRequested) () EncryptedChatClass { return & }

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

	_ EncryptedChatClass = &EncryptedChatRequested{}
)

func ( *EncryptedChatRequested) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.FolderID == 0) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.GA == nil) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedChatRequested from given interface.
func ( *EncryptedChatRequested) ( interface {
	() ( int,  bool)
	() ( int)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( []byte)
}) {
	if ,  := .();  {
		.FolderID = 
	}

	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.GA = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedChatRequested) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedChatRequested",
		ID:   EncryptedChatRequestedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "GA",
			SchemaName: "g_a",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *EncryptedChatRequested) () {
	if !(.FolderID == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *EncryptedChatRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatRequested#48f1d94c as nil")
	}
	.PutID(EncryptedChatRequestedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedChatRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatRequested#48f1d94c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode encryptedChatRequested#48f1d94c: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.FolderID)
	}
	.PutInt(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	.PutBytes(.GA)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedChatRequested) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedChatRequested#48f1d94c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field folder_id: %w", )
		}
		.FolderID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatRequested#48f1d94c: field g_a: %w", )
		}
		.GA = 
	}
	return nil
}

// SetFolderID sets value of FolderID conditional field.
func ( *EncryptedChatRequested) ( int) {
	.Flags.Set(0)
	.FolderID = 
}

// GetFolderID returns value of FolderID conditional field and
// boolean which is true if field was set.
func ( *EncryptedChatRequested) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .FolderID, true
}

// GetID returns value of ID field.
func ( *EncryptedChatRequested) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *EncryptedChatRequested) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *EncryptedChatRequested) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *EncryptedChatRequested) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *EncryptedChatRequested) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

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

// EncryptedChat represents TL type `encryptedChat#61f0d4c7`.
// Encrypted chat
//
// See https://core.telegram.org/constructor/encryptedChat for reference.
type EncryptedChat struct {
	// Chat ID
	ID int
	// Check sum dependent on the user ID
	AccessHash int64
	// Date chat was created
	Date int
	// Chat creator ID
	AdminID int64
	// ID of the second chat participant
	ParticipantID int64
	// B = g ^ b mod p, if the currently authorized user is the chat's creator,or A = g ^ a
	// mod p otherwiseSee Wikipedia¹ for more info
	//
	// Links:
	//  1) https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange
	GAOrB []byte
	// 64-bit fingerprint of received key
	KeyFingerprint int64
}

// EncryptedChatTypeID is TL type id of EncryptedChat.
const EncryptedChatTypeID = 0x61f0d4c7

// construct implements constructor of EncryptedChatClass.
func ( EncryptedChat) () EncryptedChatClass { return & }

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

	_ EncryptedChatClass = &EncryptedChat{}
)

func ( *EncryptedChat) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.AdminID == 0) {
		return false
	}
	if !(.ParticipantID == 0) {
		return false
	}
	if !(.GAOrB == nil) {
		return false
	}
	if !(.KeyFingerprint == 0) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedChat from given interface.
func ( *EncryptedChat) ( interface {
	() ( int)
	() ( int64)
	() ( int)
	() ( int64)
	() ( int64)
	() ( []byte)
	() ( int64)
}) {
	.ID = .()
	.AccessHash = .()
	.Date = .()
	.AdminID = .()
	.ParticipantID = .()
	.GAOrB = .()
	.KeyFingerprint = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedChat) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedChat",
		ID:   EncryptedChatTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "AdminID",
			SchemaName: "admin_id",
		},
		{
			Name:       "ParticipantID",
			SchemaName: "participant_id",
		},
		{
			Name:       "GAOrB",
			SchemaName: "g_a_or_b",
		},
		{
			Name:       "KeyFingerprint",
			SchemaName: "key_fingerprint",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *EncryptedChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChat#61f0d4c7 as nil")
	}
	.PutID(EncryptedChatTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChat#61f0d4c7 as nil")
	}
	.PutInt(.ID)
	.PutLong(.AccessHash)
	.PutInt(.Date)
	.PutLong(.AdminID)
	.PutLong(.ParticipantID)
	.PutBytes(.GAOrB)
	.PutLong(.KeyFingerprint)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedChat) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedChat#61f0d4c7 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field admin_id: %w", )
		}
		.AdminID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field participant_id: %w", )
		}
		.ParticipantID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field g_a_or_b: %w", )
		}
		.GAOrB = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChat#61f0d4c7: field key_fingerprint: %w", )
		}
		.KeyFingerprint = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *EncryptedChat) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *EncryptedChat) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetDate returns value of Date field.
func ( *EncryptedChat) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetAdminID returns value of AdminID field.
func ( *EncryptedChat) () ( int64) {
	if  == nil {
		return
	}
	return .AdminID
}

// GetParticipantID returns value of ParticipantID field.
func ( *EncryptedChat) () ( int64) {
	if  == nil {
		return
	}
	return .ParticipantID
}

// GetGAOrB returns value of GAOrB field.
func ( *EncryptedChat) () ( []byte) {
	if  == nil {
		return
	}
	return .GAOrB
}

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

// EncryptedChatDiscarded represents TL type `encryptedChatDiscarded#1e1c7c45`.
// Discarded or deleted chat.
//
// See https://core.telegram.org/constructor/encryptedChatDiscarded for reference.
type EncryptedChatDiscarded struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether both users of this secret chat should also remove all of its messages
	HistoryDeleted bool
	// Chat ID
	ID int
}

// EncryptedChatDiscardedTypeID is TL type id of EncryptedChatDiscarded.
const EncryptedChatDiscardedTypeID = 0x1e1c7c45

// construct implements constructor of EncryptedChatClass.
func ( EncryptedChatDiscarded) () EncryptedChatClass { return & }

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

	_ EncryptedChatClass = &EncryptedChatDiscarded{}
)

func ( *EncryptedChatDiscarded) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.HistoryDeleted == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills EncryptedChatDiscarded from given interface.
func ( *EncryptedChatDiscarded) ( interface {
	() ( bool)
	() ( int)
}) {
	.HistoryDeleted = .()
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *EncryptedChatDiscarded) () tdp.Type {
	 := tdp.Type{
		Name: "encryptedChatDiscarded",
		ID:   EncryptedChatDiscardedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "HistoryDeleted",
			SchemaName: "history_deleted",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *EncryptedChatDiscarded) () {
	if !(.HistoryDeleted == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *EncryptedChatDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatDiscarded#1e1c7c45 as nil")
	}
	.PutID(EncryptedChatDiscardedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *EncryptedChatDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode encryptedChatDiscarded#1e1c7c45 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode encryptedChatDiscarded#1e1c7c45: field flags: %w", )
	}
	.PutInt(.ID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *EncryptedChatDiscarded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode encryptedChatDiscarded#1e1c7c45 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode encryptedChatDiscarded#1e1c7c45: field flags: %w", )
		}
	}
	.HistoryDeleted = .Flags.Has(0)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode encryptedChatDiscarded#1e1c7c45: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// SetHistoryDeleted sets value of HistoryDeleted conditional field.
func ( *EncryptedChatDiscarded) ( bool) {
	if  {
		.Flags.Set(0)
		.HistoryDeleted = true
	} else {
		.Flags.Unset(0)
		.HistoryDeleted = false
	}
}

// GetHistoryDeleted returns value of HistoryDeleted conditional field.
func ( *EncryptedChatDiscarded) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetID returns value of ID field.
func ( *EncryptedChatDiscarded) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// EncryptedChatClassName is schema name of EncryptedChatClass.
const EncryptedChatClassName = "EncryptedChat"

// EncryptedChatClass represents EncryptedChat generic type.
//
// See https://core.telegram.org/type/EncryptedChat for reference.
//
// Example:
//
//	g, err := tg.DecodeEncryptedChat(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.EncryptedChatEmpty: // encryptedChatEmpty#ab7ec0a0
//	case *tg.EncryptedChatWaiting: // encryptedChatWaiting#66b25953
//	case *tg.EncryptedChatRequested: // encryptedChatRequested#48f1d94c
//	case *tg.EncryptedChat: // encryptedChat#61f0d4c7
//	case *tg.EncryptedChatDiscarded: // encryptedChatDiscarded#1e1c7c45
//	default: panic(v)
//	}
type EncryptedChatClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EncryptedChatClass

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

	// Chat ID
	GetID() (value int)

	// AsNotEmpty tries to map EncryptedChatClass to NotEmptyEncryptedChat.
	AsNotEmpty() (NotEmptyEncryptedChat, bool)
}

// AsInput tries to map EncryptedChat to InputEncryptedChat.
func ( *EncryptedChat) () *InputEncryptedChat {
	 := new(InputEncryptedChat)
	.ChatID = .GetID()
	.AccessHash = .GetAccessHash()

	return 
}

// NotEmptyEncryptedChat represents NotEmpty subset of EncryptedChatClass.
type NotEmptyEncryptedChat interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EncryptedChatClass

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

	// Chat ID
	GetID() (value int)
}

// AsNotEmpty tries to map EncryptedChatEmpty to NotEmptyEncryptedChat.
func ( *EncryptedChatEmpty) () (NotEmptyEncryptedChat, bool) {
	,  := (EncryptedChatClass()).(NotEmptyEncryptedChat)
	return , 
}

// AsNotEmpty tries to map EncryptedChatWaiting to NotEmptyEncryptedChat.
func ( *EncryptedChatWaiting) () (NotEmptyEncryptedChat, bool) {
	,  := (EncryptedChatClass()).(NotEmptyEncryptedChat)
	return , 
}

// AsNotEmpty tries to map EncryptedChatRequested to NotEmptyEncryptedChat.
func ( *EncryptedChatRequested) () (NotEmptyEncryptedChat, bool) {
	,  := (EncryptedChatClass()).(NotEmptyEncryptedChat)
	return , 
}

// AsNotEmpty tries to map EncryptedChat to NotEmptyEncryptedChat.
func ( *EncryptedChat) () (NotEmptyEncryptedChat, bool) {
	,  := (EncryptedChatClass()).(NotEmptyEncryptedChat)
	return , 
}

// AsNotEmpty tries to map EncryptedChatDiscarded to NotEmptyEncryptedChat.
func ( *EncryptedChatDiscarded) () (NotEmptyEncryptedChat, bool) {
	,  := (EncryptedChatClass()).(NotEmptyEncryptedChat)
	return , 
}

// DecodeEncryptedChat implements binary de-serialization for EncryptedChatClass.
func ( *bin.Buffer) (EncryptedChatClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case EncryptedChatEmptyTypeID:
		// Decoding encryptedChatEmpty#ab7ec0a0.
		 := EncryptedChatEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", )
		}
		return &, nil
	case EncryptedChatWaitingTypeID:
		// Decoding encryptedChatWaiting#66b25953.
		 := EncryptedChatWaiting{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", )
		}
		return &, nil
	case EncryptedChatRequestedTypeID:
		// Decoding encryptedChatRequested#48f1d94c.
		 := EncryptedChatRequested{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", )
		}
		return &, nil
	case EncryptedChatTypeID:
		// Decoding encryptedChat#61f0d4c7.
		 := EncryptedChat{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", )
		}
		return &, nil
	case EncryptedChatDiscardedTypeID:
		// Decoding encryptedChatDiscarded#1e1c7c45.
		 := EncryptedChatDiscarded{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode EncryptedChatClass: %w", bin.NewUnexpectedID())
	}
}

// EncryptedChat boxes the EncryptedChatClass providing a helper.
type EncryptedChatBox struct {
	EncryptedChat EncryptedChatClass
}

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

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