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

// PageListOrderedItemText represents TL type `pageListOrderedItemText#5e068047`.
// Ordered list of text items
//
// See https://core.telegram.org/constructor/pageListOrderedItemText for reference.
type PageListOrderedItemText struct {
	// Number of element within ordered list
	Num string
	// Text
	Text RichTextClass
}

// PageListOrderedItemTextTypeID is TL type id of PageListOrderedItemText.
const PageListOrderedItemTextTypeID = 0x5e068047

// construct implements constructor of PageListOrderedItemClass.
func ( PageListOrderedItemText) () PageListOrderedItemClass { return & }

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

	_ PageListOrderedItemClass = &PageListOrderedItemText{}
)

func ( *PageListOrderedItemText) () bool {
	if  == nil {
		return true
	}
	if !(.Num == "") {
		return false
	}
	if !(.Text == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageListOrderedItemText from given interface.
func ( *PageListOrderedItemText) ( interface {
	() ( string)
	() ( RichTextClass)
}) {
	.Num = .()
	.Text = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PageListOrderedItemText) () tdp.Type {
	 := tdp.Type{
		Name: "pageListOrderedItemText",
		ID:   PageListOrderedItemTextTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Num",
			SchemaName: "num",
		},
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PageListOrderedItemText) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageListOrderedItemText#5e068047 as nil")
	}
	.PutID(PageListOrderedItemTextTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PageListOrderedItemText) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageListOrderedItemText#5e068047 as nil")
	}
	.PutString(.Num)
	if .Text == nil {
		return fmt.Errorf("unable to encode pageListOrderedItemText#5e068047: field text is nil")
	}
	if  := .Text.Encode();  != nil {
		return fmt.Errorf("unable to encode pageListOrderedItemText#5e068047: field text: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PageListOrderedItemText) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageListOrderedItemText#5e068047 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode pageListOrderedItemText#5e068047: field num: %w", )
		}
		.Num = 
	}
	{
		,  := DecodeRichText()
		if  != nil {
			return fmt.Errorf("unable to decode pageListOrderedItemText#5e068047: field text: %w", )
		}
		.Text = 
	}
	return nil
}

// GetNum returns value of Num field.
func ( *PageListOrderedItemText) () ( string) {
	if  == nil {
		return
	}
	return .Num
}

// GetText returns value of Text field.
func ( *PageListOrderedItemText) () ( RichTextClass) {
	if  == nil {
		return
	}
	return .Text
}

// PageListOrderedItemBlocks represents TL type `pageListOrderedItemBlocks#98dd8936`.
// Ordered list of IVĀ¹ blocks
//
// Links:
//  1. https://instantview.telegram.org
//
// See https://core.telegram.org/constructor/pageListOrderedItemBlocks for reference.
type PageListOrderedItemBlocks struct {
	// Number of element within ordered list
	Num string
	// Item contents
	Blocks []PageBlockClass
}

// PageListOrderedItemBlocksTypeID is TL type id of PageListOrderedItemBlocks.
const PageListOrderedItemBlocksTypeID = 0x98dd8936

// construct implements constructor of PageListOrderedItemClass.
func ( PageListOrderedItemBlocks) () PageListOrderedItemClass { return & }

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

	_ PageListOrderedItemClass = &PageListOrderedItemBlocks{}
)

func ( *PageListOrderedItemBlocks) () bool {
	if  == nil {
		return true
	}
	if !(.Num == "") {
		return false
	}
	if !(.Blocks == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageListOrderedItemBlocks from given interface.
func ( *PageListOrderedItemBlocks) ( interface {
	() ( string)
	() ( []PageBlockClass)
}) {
	.Num = .()
	.Blocks = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PageListOrderedItemBlocks) () tdp.Type {
	 := tdp.Type{
		Name: "pageListOrderedItemBlocks",
		ID:   PageListOrderedItemBlocksTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Num",
			SchemaName: "num",
		},
		{
			Name:       "Blocks",
			SchemaName: "blocks",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PageListOrderedItemBlocks) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageListOrderedItemBlocks#98dd8936 as nil")
	}
	.PutID(PageListOrderedItemBlocksTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PageListOrderedItemBlocks) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageListOrderedItemBlocks#98dd8936 as nil")
	}
	.PutString(.Num)
	.PutVectorHeader(len(.Blocks))
	for ,  := range .Blocks {
		if  == nil {
			return fmt.Errorf("unable to encode pageListOrderedItemBlocks#98dd8936: field blocks element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode pageListOrderedItemBlocks#98dd8936: field blocks element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PageListOrderedItemBlocks) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageListOrderedItemBlocks#98dd8936 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode pageListOrderedItemBlocks#98dd8936: field num: %w", )
		}
		.Num = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode pageListOrderedItemBlocks#98dd8936: field blocks: %w", )
		}

		if  > 0 {
			.Blocks = make([]PageBlockClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodePageBlock()
			if  != nil {
				return fmt.Errorf("unable to decode pageListOrderedItemBlocks#98dd8936: field blocks: %w", )
			}
			.Blocks = append(.Blocks, )
		}
	}
	return nil
}

// GetNum returns value of Num field.
func ( *PageListOrderedItemBlocks) () ( string) {
	if  == nil {
		return
	}
	return .Num
}

// GetBlocks returns value of Blocks field.
func ( *PageListOrderedItemBlocks) () ( []PageBlockClass) {
	if  == nil {
		return
	}
	return .Blocks
}

// MapBlocks returns field Blocks wrapped in PageBlockClassArray helper.
func ( *PageListOrderedItemBlocks) () ( PageBlockClassArray) {
	return PageBlockClassArray(.Blocks)
}

// PageListOrderedItemClassName is schema name of PageListOrderedItemClass.
const PageListOrderedItemClassName = "PageListOrderedItem"

// PageListOrderedItemClass represents PageListOrderedItem generic type.
//
// See https://core.telegram.org/type/PageListOrderedItem for reference.
//
// Example:
//
//	g, err := tg.DecodePageListOrderedItem(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PageListOrderedItemText: // pageListOrderedItemText#5e068047
//	case *tg.PageListOrderedItemBlocks: // pageListOrderedItemBlocks#98dd8936
//	default: panic(v)
//	}
type PageListOrderedItemClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PageListOrderedItemClass

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

	// Number of element within ordered list
	GetNum() (value string)
}

// DecodePageListOrderedItem implements binary de-serialization for PageListOrderedItemClass.
func ( *bin.Buffer) (PageListOrderedItemClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PageListOrderedItemTextTypeID:
		// Decoding pageListOrderedItemText#5e068047.
		 := PageListOrderedItemText{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PageListOrderedItemClass: %w", )
		}
		return &, nil
	case PageListOrderedItemBlocksTypeID:
		// Decoding pageListOrderedItemBlocks#98dd8936.
		 := PageListOrderedItemBlocks{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PageListOrderedItemClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PageListOrderedItemClass: %w", bin.NewUnexpectedID())
	}
}

// PageListOrderedItem boxes the PageListOrderedItemClass providing a helper.
type PageListOrderedItemBox struct {
	PageListOrderedItem PageListOrderedItemClass
}

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

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