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

// MessagesMessageViews represents TL type `messages.messageViews#b6c4f543`.
// View, forward counter + info about replies
//
// See https://core.telegram.org/constructor/messages.messageViews for reference.
type MessagesMessageViews struct {
	// View, forward counter + info about replies
	Views []MessageViews
	// Chats mentioned in constructor
	Chats []ChatClass
	// Users mentioned in constructor
	Users []UserClass
}

// MessagesMessageViewsTypeID is TL type id of MessagesMessageViews.
const MessagesMessageViewsTypeID = 0xb6c4f543

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

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

	return true
}

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

// FillFrom fills MessagesMessageViews from given interface.
func ( *MessagesMessageViews) ( interface {
	() ( []MessageViews)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Views = .()
	.Chats = .()
	.Users = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesMessageViews) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.messageViews#b6c4f543 as nil")
	}
	.PutID(MessagesMessageViewsTypeID)
	return .EncodeBare()
}

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

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

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

		if  > 0 {
			.Views = make([]MessageViews, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  MessageViews
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.messageViews#b6c4f543: field views: %w", )
			}
			.Views = append(.Views, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.messageViews#b6c4f543: field chats: %w", )
		}

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

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

// GetViews returns value of Views field.
func ( *MessagesMessageViews) () ( []MessageViews) {
	if  == nil {
		return
	}
	return .Views
}

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

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

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

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