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

// MessagesMessages represents TL type `messages.messages#8c718e87`.
// Full list of messages with auxiliary data.
//
// See https://core.telegram.org/constructor/messages.messages for reference.
type MessagesMessages struct {
	// List of messages
	Messages []MessageClass
	// List of chats mentioned in dialogs
	Chats []ChatClass
	// List of users mentioned in messages and chats
	Users []UserClass
}

// MessagesMessagesTypeID is TL type id of MessagesMessages.
const MessagesMessagesTypeID = 0x8c718e87

// construct implements constructor of MessagesMessagesClass.
func ( MessagesMessages) () MessagesMessagesClass { return & }

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

	_ MessagesMessagesClass = &MessagesMessages{}
)

func ( *MessagesMessages) () bool {
	if  == nil {
		return true
	}
	if !(.Messages == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesMessages from given interface.
func ( *MessagesMessages) ( interface {
	() ( []MessageClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Messages = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesMessages) () tdp.Type {
	 := tdp.Type{
		Name: "messages.messages",
		ID:   MessagesMessagesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messages#8c718e87 as nil")
	}
	.PutID(MessagesMessagesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messages#8c718e87 as nil")
	}
	.PutVectorHeader(len(.Messages))
	for ,  := range .Messages {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messages#8c718e87: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messages#8c718e87 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messages#8c718e87: field messages: %w", )
		}

		if  > 0 {
			.Messages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode messages.messages#8c718e87: field messages: %w", )
			}
			.Messages = append(.Messages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messages#8c718e87: field chats: %w", )
		}

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

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

// GetMessages returns value of Messages field.
func ( *MessagesMessages) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .Messages
}

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

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

// MapMessages returns field Messages wrapped in MessageClassArray helper.
func ( *MessagesMessages) () ( MessageClassArray) {
	return MessageClassArray(.Messages)
}

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

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

// MessagesMessagesSlice represents TL type `messages.messagesSlice#3a54685e`.
// Incomplete list of messages and auxiliary data.
//
// See https://core.telegram.org/constructor/messages.messagesSlice for reference.
type MessagesMessagesSlice struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, indicates that the results may be inexact
	Inexact bool
	// Total number of messages in the list
	Count int
	// Rate to use in the offset_rate parameter in the next call to messages.searchGlobal¹
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.searchGlobal
	//
	// Use SetNextRate and GetNextRate helpers.
	NextRate int
	// Indicates the absolute position of messages[0] within the total result set with count
	// count. This is useful, for example, if the result was fetched using offset_id, and we
	// need to display a progress/total counter (like photo 134 of 200, for all media in a
	// chat, we could simply use photo ${offset_id_offset} of ${count}.
	//
	// Use SetOffsetIDOffset and GetOffsetIDOffset helpers.
	OffsetIDOffset int
	// List of messages
	Messages []MessageClass
	// List of chats mentioned in messages
	Chats []ChatClass
	// List of users mentioned in messages and chats
	Users []UserClass
}

// MessagesMessagesSliceTypeID is TL type id of MessagesMessagesSlice.
const MessagesMessagesSliceTypeID = 0x3a54685e

// construct implements constructor of MessagesMessagesClass.
func ( MessagesMessagesSlice) () MessagesMessagesClass { return & }

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

	_ MessagesMessagesClass = &MessagesMessagesSlice{}
)

func ( *MessagesMessagesSlice) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inexact == false) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.NextRate == 0) {
		return false
	}
	if !(.OffsetIDOffset == 0) {
		return false
	}
	if !(.Messages == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesMessagesSlice from given interface.
func ( *MessagesMessagesSlice) ( interface {
	() ( bool)
	() ( int)
	() ( int,  bool)
	() ( int,  bool)
	() ( []MessageClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Inexact = .()
	.Count = .()
	if ,  := .();  {
		.NextRate = 
	}

	if ,  := .();  {
		.OffsetIDOffset = 
	}

	.Messages = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesMessagesSlice) () string {
	return "messages.messagesSlice"
}

// TypeInfo returns info about TL type.
func ( *MessagesMessagesSlice) () tdp.Type {
	 := tdp.Type{
		Name: "messages.messagesSlice",
		ID:   MessagesMessagesSliceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inexact",
			SchemaName: "inexact",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "NextRate",
			SchemaName: "next_rate",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "OffsetIDOffset",
			SchemaName: "offset_id_offset",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesMessagesSlice) () {
	if !(.Inexact == false) {
		.Flags.Set(1)
	}
	if !(.NextRate == 0) {
		.Flags.Set(0)
	}
	if !(.OffsetIDOffset == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesMessagesSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messagesSlice#3a54685e as nil")
	}
	.PutID(MessagesMessagesSliceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesMessagesSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messagesSlice#3a54685e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field flags: %w", )
	}
	.PutInt(.Count)
	if .Flags.Has(0) {
		.PutInt(.NextRate)
	}
	if .Flags.Has(2) {
		.PutInt(.OffsetIDOffset)
	}
	.PutVectorHeader(len(.Messages))
	for ,  := range .Messages {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.messagesSlice#3a54685e: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesMessagesSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messagesSlice#3a54685e to nil")
	}
	if  := .ConsumeID(MessagesMessagesSliceTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesMessagesSlice) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messagesSlice#3a54685e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field flags: %w", )
		}
	}
	.Inexact = .Flags.Has(1)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field count: %w", )
		}
		.Count = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field next_rate: %w", )
		}
		.NextRate = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field offset_id_offset: %w", )
		}
		.OffsetIDOffset = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field messages: %w", )
		}

		if  > 0 {
			.Messages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field messages: %w", )
			}
			.Messages = append(.Messages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field chats: %w", )
		}

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

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode messages.messagesSlice#3a54685e: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// SetInexact sets value of Inexact conditional field.
func ( *MessagesMessagesSlice) ( bool) {
	if  {
		.Flags.Set(1)
		.Inexact = true
	} else {
		.Flags.Unset(1)
		.Inexact = false
	}
}

// GetInexact returns value of Inexact conditional field.
func ( *MessagesMessagesSlice) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetCount returns value of Count field.
func ( *MessagesMessagesSlice) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// SetNextRate sets value of NextRate conditional field.
func ( *MessagesMessagesSlice) ( int) {
	.Flags.Set(0)
	.NextRate = 
}

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

// SetOffsetIDOffset sets value of OffsetIDOffset conditional field.
func ( *MessagesMessagesSlice) ( int) {
	.Flags.Set(2)
	.OffsetIDOffset = 
}

// GetOffsetIDOffset returns value of OffsetIDOffset conditional field and
// boolean which is true if field was set.
func ( *MessagesMessagesSlice) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .OffsetIDOffset, true
}

// GetMessages returns value of Messages field.
func ( *MessagesMessagesSlice) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .Messages
}

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

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

// MapMessages returns field Messages wrapped in MessageClassArray helper.
func ( *MessagesMessagesSlice) () ( MessageClassArray) {
	return MessageClassArray(.Messages)
}

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

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

// MessagesChannelMessages represents TL type `messages.channelMessages#c776ba4e`.
// Channel messages
//
// See https://core.telegram.org/constructor/messages.channelMessages for reference.
type MessagesChannelMessages struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, returned results may be inexact
	Inexact bool
	// Event count after generation¹
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	Pts int
	// Total number of results were found server-side (may not be all included here)
	Count int
	// Indicates the absolute position of messages[0] within the total result set with count
	// count. This is useful, for example, if the result was fetched using offset_id, and we
	// need to display a progress/total counter (like photo 134 of 200, for all media in a
	// chat, we could simply use photo ${offset_id_offset} of ${count}.
	//
	// Use SetOffsetIDOffset and GetOffsetIDOffset helpers.
	OffsetIDOffset int
	// Found messages
	Messages []MessageClass
	// Forum topic¹ information
	//
	// Links:
	//  1) https://core.telegram.org/api/forum#forum-topics
	Topics []ForumTopicClass
	// Chats
	Chats []ChatClass
	// Users
	Users []UserClass
}

// MessagesChannelMessagesTypeID is TL type id of MessagesChannelMessages.
const MessagesChannelMessagesTypeID = 0xc776ba4e

// construct implements constructor of MessagesMessagesClass.
func ( MessagesChannelMessages) () MessagesMessagesClass { return & }

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

	_ MessagesMessagesClass = &MessagesChannelMessages{}
)

func ( *MessagesChannelMessages) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inexact == false) {
		return false
	}
	if !(.Pts == 0) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.OffsetIDOffset == 0) {
		return false
	}
	if !(.Messages == nil) {
		return false
	}
	if !(.Topics == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesChannelMessages from given interface.
func ( *MessagesChannelMessages) ( interface {
	() ( bool)
	() ( int)
	() ( int)
	() ( int,  bool)
	() ( []MessageClass)
	() ( []ForumTopicClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Inexact = .()
	.Pts = .()
	.Count = .()
	if ,  := .();  {
		.OffsetIDOffset = 
	}

	.Messages = .()
	.Topics = .()
	.Chats = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesChannelMessages) () string {
	return "messages.channelMessages"
}

// TypeInfo returns info about TL type.
func ( *MessagesChannelMessages) () tdp.Type {
	 := tdp.Type{
		Name: "messages.channelMessages",
		ID:   MessagesChannelMessagesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inexact",
			SchemaName: "inexact",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Pts",
			SchemaName: "pts",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "OffsetIDOffset",
			SchemaName: "offset_id_offset",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Messages",
			SchemaName: "messages",
		},
		{
			Name:       "Topics",
			SchemaName: "topics",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesChannelMessages) () {
	if !(.Inexact == false) {
		.Flags.Set(1)
	}
	if !(.OffsetIDOffset == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesChannelMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.channelMessages#c776ba4e as nil")
	}
	.PutID(MessagesChannelMessagesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesChannelMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.channelMessages#c776ba4e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field flags: %w", )
	}
	.PutInt(.Pts)
	.PutInt(.Count)
	if .Flags.Has(2) {
		.PutInt(.OffsetIDOffset)
	}
	.PutVectorHeader(len(.Messages))
	for ,  := range .Messages {
		if  == nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field messages element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field messages element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Topics))
	for ,  := range .Topics {
		if  == nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field topics element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field topics element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.channelMessages#c776ba4e: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesChannelMessages) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.channelMessages#c776ba4e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field flags: %w", )
		}
	}
	.Inexact = .Flags.Has(1)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field pts: %w", )
		}
		.Pts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field count: %w", )
		}
		.Count = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field offset_id_offset: %w", )
		}
		.OffsetIDOffset = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field messages: %w", )
		}

		if  > 0 {
			.Messages = make([]MessageClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessage()
			if  != nil {
				return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field messages: %w", )
			}
			.Messages = append(.Messages, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field topics: %w", )
		}

		if  > 0 {
			.Topics = make([]ForumTopicClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeForumTopic()
			if  != nil {
				return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field topics: %w", )
			}
			.Topics = append(.Topics, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.channelMessages#c776ba4e: field chats: %w", )
		}

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

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

// SetInexact sets value of Inexact conditional field.
func ( *MessagesChannelMessages) ( bool) {
	if  {
		.Flags.Set(1)
		.Inexact = true
	} else {
		.Flags.Unset(1)
		.Inexact = false
	}
}

// GetInexact returns value of Inexact conditional field.
func ( *MessagesChannelMessages) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

// GetCount returns value of Count field.
func ( *MessagesChannelMessages) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// SetOffsetIDOffset sets value of OffsetIDOffset conditional field.
func ( *MessagesChannelMessages) ( int) {
	.Flags.Set(2)
	.OffsetIDOffset = 
}

// GetOffsetIDOffset returns value of OffsetIDOffset conditional field and
// boolean which is true if field was set.
func ( *MessagesChannelMessages) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .OffsetIDOffset, true
}

// GetMessages returns value of Messages field.
func ( *MessagesChannelMessages) () ( []MessageClass) {
	if  == nil {
		return
	}
	return .Messages
}

// GetTopics returns value of Topics field.
func ( *MessagesChannelMessages) () ( []ForumTopicClass) {
	if  == nil {
		return
	}
	return .Topics
}

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

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

// MapMessages returns field Messages wrapped in MessageClassArray helper.
func ( *MessagesChannelMessages) () ( MessageClassArray) {
	return MessageClassArray(.Messages)
}

// MapTopics returns field Topics wrapped in ForumTopicClassArray helper.
func ( *MessagesChannelMessages) () ( ForumTopicClassArray) {
	return ForumTopicClassArray(.Topics)
}

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

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

// MessagesMessagesNotModified represents TL type `messages.messagesNotModified#74535f21`.
// No new messages matching the query were found
//
// See https://core.telegram.org/constructor/messages.messagesNotModified for reference.
type MessagesMessagesNotModified struct {
	// Number of results found server-side by the given query
	Count int
}

// MessagesMessagesNotModifiedTypeID is TL type id of MessagesMessagesNotModified.
const MessagesMessagesNotModifiedTypeID = 0x74535f21

// construct implements constructor of MessagesMessagesClass.
func ( MessagesMessagesNotModified) () MessagesMessagesClass { return & }

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

	_ MessagesMessagesClass = &MessagesMessagesNotModified{}
)

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

	return true
}

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

// FillFrom fills MessagesMessagesNotModified from given interface.
func ( *MessagesMessagesNotModified) ( interface {
	() ( int)
}) {
	.Count = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesMessagesNotModified) () string {
	return "messages.messagesNotModified"
}

// TypeInfo returns info about TL type.
func ( *MessagesMessagesNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "messages.messagesNotModified",
		ID:   MessagesMessagesNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesMessagesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messagesNotModified#74535f21 as nil")
	}
	.PutID(MessagesMessagesNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesMessagesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messagesNotModified#74535f21 as nil")
	}
	.PutInt(.Count)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesMessagesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messagesNotModified#74535f21 to nil")
	}
	if  := .ConsumeID(MessagesMessagesNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.messagesNotModified#74535f21: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesMessagesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.messagesNotModified#74535f21 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messagesNotModified#74535f21: field count: %w", )
		}
		.Count = 
	}
	return nil
}

// GetCount returns value of Count field.
func ( *MessagesMessagesNotModified) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// MessagesMessagesClassName is schema name of MessagesMessagesClass.
const MessagesMessagesClassName = "messages.Messages"

// MessagesMessagesClass represents messages.Messages generic type.
//
// See https://core.telegram.org/type/messages.Messages for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesMessages(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesMessages: // messages.messages#8c718e87
//	case *tg.MessagesMessagesSlice: // messages.messagesSlice#3a54685e
//	case *tg.MessagesChannelMessages: // messages.channelMessages#c776ba4e
//	case *tg.MessagesMessagesNotModified: // messages.messagesNotModified#74535f21
//	default: panic(v)
//	}
type MessagesMessagesClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesMessagesClass

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

	// AsModified tries to map MessagesMessagesClass to ModifiedMessagesMessages.
	AsModified() (ModifiedMessagesMessages, bool)
}

// ModifiedMessagesMessages represents Modified subset of MessagesMessagesClass.
type ModifiedMessagesMessages interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesMessagesClass

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

	// List of messages
	GetMessages() (value []MessageClass)

	// List of chats mentioned in dialogs
	GetChats() (value []ChatClass)

	// List of users mentioned in messages and chats
	GetUsers() (value []UserClass)
}

// AsModified tries to map MessagesMessages to ModifiedMessagesMessages.
func ( *MessagesMessages) () (ModifiedMessagesMessages, bool) {
	,  := (MessagesMessagesClass()).(ModifiedMessagesMessages)
	return , 
}

// AsModified tries to map MessagesMessagesSlice to ModifiedMessagesMessages.
func ( *MessagesMessagesSlice) () (ModifiedMessagesMessages, bool) {
	,  := (MessagesMessagesClass()).(ModifiedMessagesMessages)
	return , 
}

// AsModified tries to map MessagesChannelMessages to ModifiedMessagesMessages.
func ( *MessagesChannelMessages) () (ModifiedMessagesMessages, bool) {
	,  := (MessagesMessagesClass()).(ModifiedMessagesMessages)
	return , 
}

// AsModified tries to map MessagesMessagesNotModified to ModifiedMessagesMessages.
func ( *MessagesMessagesNotModified) () (ModifiedMessagesMessages, bool) {
	,  := (MessagesMessagesClass()).(ModifiedMessagesMessages)
	return , 
}

// DecodeMessagesMessages implements binary de-serialization for MessagesMessagesClass.
func ( *bin.Buffer) (MessagesMessagesClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesMessagesTypeID:
		// Decoding messages.messages#8c718e87.
		 := MessagesMessages{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesMessagesClass: %w", )
		}
		return &, nil
	case MessagesMessagesSliceTypeID:
		// Decoding messages.messagesSlice#3a54685e.
		 := MessagesMessagesSlice{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesMessagesClass: %w", )
		}
		return &, nil
	case MessagesChannelMessagesTypeID:
		// Decoding messages.channelMessages#c776ba4e.
		 := MessagesChannelMessages{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesMessagesClass: %w", )
		}
		return &, nil
	case MessagesMessagesNotModifiedTypeID:
		// Decoding messages.messagesNotModified#74535f21.
		 := MessagesMessagesNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesMessagesClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesMessagesClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesMessages boxes the MessagesMessagesClass providing a helper.
type MessagesMessagesBox struct {
	Messages MessagesMessagesClass
}

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

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