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

// MessagesWebPage represents TL type `messages.webPage#fd5e12bd`.
// Represents an Instant View webpage.
//
// See https://core.telegram.org/constructor/messages.webPage for reference.
type MessagesWebPage struct {
	// The instant view webpage.
	Webpage WebPageClass
	// Chats mentioned in the webpage.
	Chats []ChatClass
	// Users mentioned in the webpage.
	Users []UserClass
}

// MessagesWebPageTypeID is TL type id of MessagesWebPage.
const MessagesWebPageTypeID = 0xfd5e12bd

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

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

	return true
}

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

// FillFrom fills MessagesWebPage from given interface.
func ( *MessagesWebPage) ( interface {
	() ( WebPageClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Webpage = .()
	.Chats = .()
	.Users = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *MessagesWebPage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.webPage#fd5e12bd as nil")
	}
	.PutID(MessagesWebPageTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesWebPage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.webPage#fd5e12bd to nil")
	}
	{
		,  := DecodeWebPage()
		if  != nil {
			return fmt.Errorf("unable to decode messages.webPage#fd5e12bd: field webpage: %w", )
		}
		.Webpage = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.webPage#fd5e12bd: field chats: %w", )
		}

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

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

// GetWebpage returns value of Webpage field.
func ( *MessagesWebPage) () ( WebPageClass) {
	if  == nil {
		return
	}
	return .Webpage
}

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

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

// GetWebpageAsModified returns mapped value of Webpage field.
func ( *MessagesWebPage) () (ModifiedWebPage, bool) {
	return .Webpage.AsModified()
}

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

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