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

// UpdatesDifferenceEmpty represents TL type `updates.differenceEmpty#5d75a138`.
// No events.
//
// See https://core.telegram.org/constructor/updates.differenceEmpty for reference.
type UpdatesDifferenceEmpty struct {
	// Current date
	Date int
	// Number of sent updates
	Seq int
}

// UpdatesDifferenceEmptyTypeID is TL type id of UpdatesDifferenceEmpty.
const UpdatesDifferenceEmptyTypeID = 0x5d75a138

// construct implements constructor of UpdatesDifferenceClass.
func ( UpdatesDifferenceEmpty) () UpdatesDifferenceClass { return & }

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

	_ UpdatesDifferenceClass = &UpdatesDifferenceEmpty{}
)

func ( *UpdatesDifferenceEmpty) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Seq == 0) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesDifferenceEmpty from given interface.
func ( *UpdatesDifferenceEmpty) ( interface {
	() ( int)
	() ( int)
}) {
	.Date = .()
	.Seq = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesDifferenceEmpty) () string {
	return "updates.differenceEmpty"
}

// TypeInfo returns info about TL type.
func ( *UpdatesDifferenceEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "updates.differenceEmpty",
		ID:   UpdatesDifferenceEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Seq",
			SchemaName: "seq",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UpdatesDifferenceEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceEmpty#5d75a138 as nil")
	}
	.PutID(UpdatesDifferenceEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesDifferenceEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceEmpty#5d75a138 as nil")
	}
	.PutInt(.Date)
	.PutInt(.Seq)
	return nil
}

// Decode implements bin.Decoder.
func ( *UpdatesDifferenceEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.differenceEmpty#5d75a138 to nil")
	}
	if  := .ConsumeID(UpdatesDifferenceEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode updates.differenceEmpty#5d75a138: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesDifferenceEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.differenceEmpty#5d75a138 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceEmpty#5d75a138: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceEmpty#5d75a138: field seq: %w", )
		}
		.Seq = 
	}
	return nil
}

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

// GetSeq returns value of Seq field.
func ( *UpdatesDifferenceEmpty) () ( int) {
	if  == nil {
		return
	}
	return .Seq
}

// UpdatesDifference represents TL type `updates.difference#f49ca0`.
// Full list of occurred events.
//
// See https://core.telegram.org/constructor/updates.difference for reference.
type UpdatesDifference struct {
	// List of new messages
	NewMessages []MessageClass
	// List of new encrypted secret chat messages
	NewEncryptedMessages []EncryptedMessageClass
	// List of updates
	OtherUpdates []UpdateClass
	// List of chats mentioned in events
	Chats []ChatClass
	// List of users mentioned in events
	Users []UserClass
	// Current state
	State UpdatesState
}

// UpdatesDifferenceTypeID is TL type id of UpdatesDifference.
const UpdatesDifferenceTypeID = 0xf49ca0

// construct implements constructor of UpdatesDifferenceClass.
func ( UpdatesDifference) () UpdatesDifferenceClass { return & }

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

	_ UpdatesDifferenceClass = &UpdatesDifference{}
)

func ( *UpdatesDifference) () bool {
	if  == nil {
		return true
	}
	if !(.NewMessages == nil) {
		return false
	}
	if !(.NewEncryptedMessages == nil) {
		return false
	}
	if !(.OtherUpdates == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.State.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesDifference from given interface.
func ( *UpdatesDifference) ( interface {
	() ( []MessageClass)
	() ( []EncryptedMessageClass)
	() ( []UpdateClass)
	() ( []ChatClass)
	() ( []UserClass)
	() ( UpdatesState)
}) {
	.NewMessages = .()
	.NewEncryptedMessages = .()
	.OtherUpdates = .()
	.Chats = .()
	.Users = .()
	.State = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesDifference) () string {
	return "updates.difference"
}

// TypeInfo returns info about TL type.
func ( *UpdatesDifference) () tdp.Type {
	 := tdp.Type{
		Name: "updates.difference",
		ID:   UpdatesDifferenceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NewMessages",
			SchemaName: "new_messages",
		},
		{
			Name:       "NewEncryptedMessages",
			SchemaName: "new_encrypted_messages",
		},
		{
			Name:       "OtherUpdates",
			SchemaName: "other_updates",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "State",
			SchemaName: "state",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UpdatesDifference) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.difference#f49ca0 as nil")
	}
	.PutID(UpdatesDifferenceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesDifference) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.difference#f49ca0 as nil")
	}
	.PutVectorHeader(len(.NewMessages))
	for ,  := range .NewMessages {
		if  == nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field new_messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field new_messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.NewEncryptedMessages))
	for ,  := range .NewEncryptedMessages {
		if  == nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field new_encrypted_messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field new_encrypted_messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.OtherUpdates))
	for ,  := range .OtherUpdates {
		if  == nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field other_updates element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field other_updates element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.difference#f49ca0: field users element with index %d: %w", , )
		}
	}
	if  := .State.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.difference#f49ca0: field state: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesDifference) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.difference#f49ca0 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field new_messages: %w", )
		}

		if  > 0 {
			.NewMessages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode updates.difference#f49ca0: field new_messages: %w", )
			}
			.NewMessages = append(.NewMessages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field new_encrypted_messages: %w", )
		}

		if  > 0 {
			.NewEncryptedMessages = make([]EncryptedMessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeEncryptedMessage()
			if  != nil {
				return fmt.Errorf("unable to decode updates.difference#f49ca0: field new_encrypted_messages: %w", )
			}
			.NewEncryptedMessages = append(.NewEncryptedMessages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field other_updates: %w", )
		}

		if  > 0 {
			.OtherUpdates = make([]UpdateClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUpdate()
			if  != nil {
				return fmt.Errorf("unable to decode updates.difference#f49ca0: field other_updates: %w", )
			}
			.OtherUpdates = append(.OtherUpdates, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode updates.difference#f49ca0: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode updates.difference#f49ca0: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	{
		if  := .State.Decode();  != nil {
			return fmt.Errorf("unable to decode updates.difference#f49ca0: field state: %w", )
		}
	}
	return nil
}

// GetNewMessages returns value of NewMessages field.
func ( *UpdatesDifference) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .NewMessages
}

// GetNewEncryptedMessages returns value of NewEncryptedMessages field.
func ( *UpdatesDifference) () ( []EncryptedMessageClass) {
	if  == nil {
		return
	}
	return .NewEncryptedMessages
}

// GetOtherUpdates returns value of OtherUpdates field.
func ( *UpdatesDifference) () ( []UpdateClass) {
	if  == nil {
		return
	}
	return .OtherUpdates
}

// GetChats returns value of Chats field.
func ( *UpdatesDifference) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *UpdatesDifference) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// GetState returns value of State field.
func ( *UpdatesDifference) () ( UpdatesState) {
	if  == nil {
		return
	}
	return .State
}

// MapNewMessages returns field NewMessages wrapped in MessageClassArray helper.
func ( *UpdatesDifference) () ( MessageClassArray) {
	return MessageClassArray(.NewMessages)
}

// MapNewEncryptedMessages returns field NewEncryptedMessages wrapped in EncryptedMessageClassArray helper.
func ( *UpdatesDifference) () ( EncryptedMessageClassArray) {
	return EncryptedMessageClassArray(.NewEncryptedMessages)
}

// MapOtherUpdates returns field OtherUpdates wrapped in UpdateClassArray helper.
func ( *UpdatesDifference) () ( UpdateClassArray) {
	return UpdateClassArray(.OtherUpdates)
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *UpdatesDifference) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *UpdatesDifference) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// UpdatesDifferenceSlice represents TL type `updates.differenceSlice#a8fb1981`.
// Incomplete list of occurred events.
//
// See https://core.telegram.org/constructor/updates.differenceSlice for reference.
type UpdatesDifferenceSlice struct {
	// List of new messages
	NewMessages []MessageClass
	// New messages from the encrypted event sequenceĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	NewEncryptedMessages []EncryptedMessageClass
	// List of updates
	OtherUpdates []UpdateClass
	// List of chats mentioned in events
	Chats []ChatClass
	// List of users mentioned in events
	Users []UserClass
	// Intermediary state
	IntermediateState UpdatesState
}

// UpdatesDifferenceSliceTypeID is TL type id of UpdatesDifferenceSlice.
const UpdatesDifferenceSliceTypeID = 0xa8fb1981

// construct implements constructor of UpdatesDifferenceClass.
func ( UpdatesDifferenceSlice) () UpdatesDifferenceClass { return & }

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

	_ UpdatesDifferenceClass = &UpdatesDifferenceSlice{}
)

func ( *UpdatesDifferenceSlice) () bool {
	if  == nil {
		return true
	}
	if !(.NewMessages == nil) {
		return false
	}
	if !(.NewEncryptedMessages == nil) {
		return false
	}
	if !(.OtherUpdates == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.IntermediateState.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesDifferenceSlice from given interface.
func ( *UpdatesDifferenceSlice) ( interface {
	() ( []MessageClass)
	() ( []EncryptedMessageClass)
	() ( []UpdateClass)
	() ( []ChatClass)
	() ( []UserClass)
	() ( UpdatesState)
}) {
	.NewMessages = .()
	.NewEncryptedMessages = .()
	.OtherUpdates = .()
	.Chats = .()
	.Users = .()
	.IntermediateState = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesDifferenceSlice) () string {
	return "updates.differenceSlice"
}

// TypeInfo returns info about TL type.
func ( *UpdatesDifferenceSlice) () tdp.Type {
	 := tdp.Type{
		Name: "updates.differenceSlice",
		ID:   UpdatesDifferenceSliceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NewMessages",
			SchemaName: "new_messages",
		},
		{
			Name:       "NewEncryptedMessages",
			SchemaName: "new_encrypted_messages",
		},
		{
			Name:       "OtherUpdates",
			SchemaName: "other_updates",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "IntermediateState",
			SchemaName: "intermediate_state",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UpdatesDifferenceSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceSlice#a8fb1981 as nil")
	}
	.PutID(UpdatesDifferenceSliceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesDifferenceSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceSlice#a8fb1981 as nil")
	}
	.PutVectorHeader(len(.NewMessages))
	for ,  := range .NewMessages {
		if  == nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field new_messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field new_messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.NewEncryptedMessages))
	for ,  := range .NewEncryptedMessages {
		if  == nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field new_encrypted_messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field new_encrypted_messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.OtherUpdates))
	for ,  := range .OtherUpdates {
		if  == nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field other_updates element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field other_updates element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field users element with index %d: %w", , )
		}
	}
	if  := .IntermediateState.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.differenceSlice#a8fb1981: field intermediate_state: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesDifferenceSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.differenceSlice#a8fb1981 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field new_messages: %w", )
		}

		if  > 0 {
			.NewMessages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field new_messages: %w", )
			}
			.NewMessages = append(.NewMessages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field new_encrypted_messages: %w", )
		}

		if  > 0 {
			.NewEncryptedMessages = make([]EncryptedMessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeEncryptedMessage()
			if  != nil {
				return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field new_encrypted_messages: %w", )
			}
			.NewEncryptedMessages = append(.NewEncryptedMessages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field other_updates: %w", )
		}

		if  > 0 {
			.OtherUpdates = make([]UpdateClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUpdate()
			if  != nil {
				return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field other_updates: %w", )
			}
			.OtherUpdates = append(.OtherUpdates, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	{
		if  := .IntermediateState.Decode();  != nil {
			return fmt.Errorf("unable to decode updates.differenceSlice#a8fb1981: field intermediate_state: %w", )
		}
	}
	return nil
}

// GetNewMessages returns value of NewMessages field.
func ( *UpdatesDifferenceSlice) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .NewMessages
}

// GetNewEncryptedMessages returns value of NewEncryptedMessages field.
func ( *UpdatesDifferenceSlice) () ( []EncryptedMessageClass) {
	if  == nil {
		return
	}
	return .NewEncryptedMessages
}

// GetOtherUpdates returns value of OtherUpdates field.
func ( *UpdatesDifferenceSlice) () ( []UpdateClass) {
	if  == nil {
		return
	}
	return .OtherUpdates
}

// GetChats returns value of Chats field.
func ( *UpdatesDifferenceSlice) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *UpdatesDifferenceSlice) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// GetIntermediateState returns value of IntermediateState field.
func ( *UpdatesDifferenceSlice) () ( UpdatesState) {
	if  == nil {
		return
	}
	return .IntermediateState
}

// MapNewMessages returns field NewMessages wrapped in MessageClassArray helper.
func ( *UpdatesDifferenceSlice) () ( MessageClassArray) {
	return MessageClassArray(.NewMessages)
}

// MapNewEncryptedMessages returns field NewEncryptedMessages wrapped in EncryptedMessageClassArray helper.
func ( *UpdatesDifferenceSlice) () ( EncryptedMessageClassArray) {
	return EncryptedMessageClassArray(.NewEncryptedMessages)
}

// MapOtherUpdates returns field OtherUpdates wrapped in UpdateClassArray helper.
func ( *UpdatesDifferenceSlice) () ( UpdateClassArray) {
	return UpdateClassArray(.OtherUpdates)
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *UpdatesDifferenceSlice) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *UpdatesDifferenceSlice) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// UpdatesDifferenceTooLong represents TL type `updates.differenceTooLong#4afe8f6d`.
// The difference is too longĀ¹, and the specified state must be used to refetch updates.
//
// Links:
//  1. https://core.telegram.org/api/updates#recovering-gaps
//
// See https://core.telegram.org/constructor/updates.differenceTooLong for reference.
type UpdatesDifferenceTooLong struct {
	// The new state to use.
	Pts int
}

// UpdatesDifferenceTooLongTypeID is TL type id of UpdatesDifferenceTooLong.
const UpdatesDifferenceTooLongTypeID = 0x4afe8f6d

// construct implements constructor of UpdatesDifferenceClass.
func ( UpdatesDifferenceTooLong) () UpdatesDifferenceClass { return & }

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

	_ UpdatesDifferenceClass = &UpdatesDifferenceTooLong{}
)

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

	return true
}

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

// FillFrom fills UpdatesDifferenceTooLong from given interface.
func ( *UpdatesDifferenceTooLong) ( interface {
	() ( int)
}) {
	.Pts = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesDifferenceTooLong) () string {
	return "updates.differenceTooLong"
}

// TypeInfo returns info about TL type.
func ( *UpdatesDifferenceTooLong) () tdp.Type {
	 := tdp.Type{
		Name: "updates.differenceTooLong",
		ID:   UpdatesDifferenceTooLongTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pts",
			SchemaName: "pts",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UpdatesDifferenceTooLong) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceTooLong#4afe8f6d as nil")
	}
	.PutID(UpdatesDifferenceTooLongTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesDifferenceTooLong) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.differenceTooLong#4afe8f6d as nil")
	}
	.PutInt(.Pts)
	return nil
}

// Decode implements bin.Decoder.
func ( *UpdatesDifferenceTooLong) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.differenceTooLong#4afe8f6d to nil")
	}
	if  := .ConsumeID(UpdatesDifferenceTooLongTypeID);  != nil {
		return fmt.Errorf("unable to decode updates.differenceTooLong#4afe8f6d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesDifferenceTooLong) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.differenceTooLong#4afe8f6d to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.differenceTooLong#4afe8f6d: field pts: %w", )
		}
		.Pts = 
	}
	return nil
}

// GetPts returns value of Pts field.
func ( *UpdatesDifferenceTooLong) () ( int) {
	if  == nil {
		return
	}
	return .Pts
}

// UpdatesDifferenceClassName is schema name of UpdatesDifferenceClass.
const UpdatesDifferenceClassName = "updates.Difference"

// UpdatesDifferenceClass represents updates.Difference generic type.
//
// See https://core.telegram.org/type/updates.Difference for reference.
//
// Example:
//
//	g, err := tg.DecodeUpdatesDifference(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.UpdatesDifferenceEmpty: // updates.differenceEmpty#5d75a138
//	case *tg.UpdatesDifference: // updates.difference#f49ca0
//	case *tg.UpdatesDifferenceSlice: // updates.differenceSlice#a8fb1981
//	case *tg.UpdatesDifferenceTooLong: // updates.differenceTooLong#4afe8f6d
//	default: panic(v)
//	}
type UpdatesDifferenceClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() UpdatesDifferenceClass

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

// DecodeUpdatesDifference implements binary de-serialization for UpdatesDifferenceClass.
func ( *bin.Buffer) (UpdatesDifferenceClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case UpdatesDifferenceEmptyTypeID:
		// Decoding updates.differenceEmpty#5d75a138.
		 := UpdatesDifferenceEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UpdatesDifferenceClass: %w", )
		}
		return &, nil
	case UpdatesDifferenceTypeID:
		// Decoding updates.difference#f49ca0.
		 := UpdatesDifference{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UpdatesDifferenceClass: %w", )
		}
		return &, nil
	case UpdatesDifferenceSliceTypeID:
		// Decoding updates.differenceSlice#a8fb1981.
		 := UpdatesDifferenceSlice{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UpdatesDifferenceClass: %w", )
		}
		return &, nil
	case UpdatesDifferenceTooLongTypeID:
		// Decoding updates.differenceTooLong#4afe8f6d.
		 := UpdatesDifferenceTooLong{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode UpdatesDifferenceClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode UpdatesDifferenceClass: %w", bin.NewUnexpectedID())
	}
}

// UpdatesDifference boxes the UpdatesDifferenceClass providing a helper.
type UpdatesDifferenceBox struct {
	Difference UpdatesDifferenceClass
}

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

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