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

// HelpUserInfoEmpty represents TL type `help.userInfoEmpty#f3ae2eed`.
// Internal use
//
// See https://core.telegram.org/constructor/help.userInfoEmpty for reference.
type HelpUserInfoEmpty struct {
}

// HelpUserInfoEmptyTypeID is TL type id of HelpUserInfoEmpty.
const HelpUserInfoEmptyTypeID = 0xf3ae2eed

// construct implements constructor of HelpUserInfoClass.
func ( HelpUserInfoEmpty) () HelpUserInfoClass { return & }

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

	_ HelpUserInfoClass = &HelpUserInfoEmpty{}
)

func ( *HelpUserInfoEmpty) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*HelpUserInfoEmpty) () string {
	return "help.userInfoEmpty"
}

// TypeInfo returns info about TL type.
func ( *HelpUserInfoEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "help.userInfoEmpty",
		ID:   HelpUserInfoEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpUserInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.userInfoEmpty#f3ae2eed as nil")
	}
	.PutID(HelpUserInfoEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpUserInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.userInfoEmpty#f3ae2eed as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpUserInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.userInfoEmpty#f3ae2eed to nil")
	}
	if  := .ConsumeID(HelpUserInfoEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode help.userInfoEmpty#f3ae2eed: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpUserInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.userInfoEmpty#f3ae2eed to nil")
	}
	return nil
}

// HelpUserInfo represents TL type `help.userInfo#1eb3758`.
// Internal use
//
// See https://core.telegram.org/constructor/help.userInfo for reference.
type HelpUserInfo struct {
	// Info
	Message string
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	Entities []MessageEntityClass
	// Author
	Author string
	// Date
	Date int
}

// HelpUserInfoTypeID is TL type id of HelpUserInfo.
const HelpUserInfoTypeID = 0x1eb3758

// construct implements constructor of HelpUserInfoClass.
func ( HelpUserInfo) () HelpUserInfoClass { return & }

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

	_ HelpUserInfoClass = &HelpUserInfo{}
)

func ( *HelpUserInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Message == "") {
		return false
	}
	if !(.Entities == nil) {
		return false
	}
	if !(.Author == "") {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills HelpUserInfo from given interface.
func ( *HelpUserInfo) ( interface {
	() ( string)
	() ( []MessageEntityClass)
	() ( string)
	() ( int)
}) {
	.Message = .()
	.Entities = .()
	.Author = .()
	.Date = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpUserInfo) () string {
	return "help.userInfo"
}

// TypeInfo returns info about TL type.
func ( *HelpUserInfo) () tdp.Type {
	 := tdp.Type{
		Name: "help.userInfo",
		ID:   HelpUserInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
		},
		{
			Name:       "Author",
			SchemaName: "author",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpUserInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.userInfo#1eb3758 as nil")
	}
	.PutID(HelpUserInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpUserInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.userInfo#1eb3758 as nil")
	}
	.PutString(.Message)
	.PutVectorHeader(len(.Entities))
	for ,  := range .Entities {
		if  == nil {
			return fmt.Errorf("unable to encode help.userInfo#1eb3758: field entities element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.userInfo#1eb3758: field entities element with index %d: %w", , )
		}
	}
	.PutString(.Author)
	.PutInt(.Date)
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpUserInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.userInfo#1eb3758 to nil")
	}
	if  := .ConsumeID(HelpUserInfoTypeID);  != nil {
		return fmt.Errorf("unable to decode help.userInfo#1eb3758: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpUserInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.userInfo#1eb3758 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode help.userInfo#1eb3758: field message: %w", )
		}
		.Message = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.userInfo#1eb3758: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode help.userInfo#1eb3758: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode help.userInfo#1eb3758: field author: %w", )
		}
		.Author = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.userInfo#1eb3758: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetMessage returns value of Message field.
func ( *HelpUserInfo) () ( string) {
	if  == nil {
		return
	}
	return .Message
}

// GetEntities returns value of Entities field.
func ( *HelpUserInfo) () ( []MessageEntityClass) {
	if  == nil {
		return
	}
	return .Entities
}

// GetAuthor returns value of Author field.
func ( *HelpUserInfo) () ( string) {
	if  == nil {
		return
	}
	return .Author
}

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

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *HelpUserInfo) () ( MessageEntityClassArray) {
	return MessageEntityClassArray(.Entities)
}

// HelpUserInfoClassName is schema name of HelpUserInfoClass.
const HelpUserInfoClassName = "help.UserInfo"

// HelpUserInfoClass represents help.UserInfo generic type.
//
// See https://core.telegram.org/type/help.UserInfo for reference.
//
// Example:
//
//	g, err := tg.DecodeHelpUserInfo(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.HelpUserInfoEmpty: // help.userInfoEmpty#f3ae2eed
//	case *tg.HelpUserInfo: // help.userInfo#1eb3758
//	default: panic(v)
//	}
type HelpUserInfoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() HelpUserInfoClass

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

	// AsNotEmpty tries to map HelpUserInfoClass to HelpUserInfo.
	AsNotEmpty() (*HelpUserInfo, bool)
}

// AsNotEmpty tries to map HelpUserInfoEmpty to HelpUserInfo.
func ( *HelpUserInfoEmpty) () (*HelpUserInfo, bool) {
	return nil, false
}

// AsNotEmpty tries to map HelpUserInfo to HelpUserInfo.
func ( *HelpUserInfo) () (*HelpUserInfo, bool) {
	return , true
}

// DecodeHelpUserInfo implements binary de-serialization for HelpUserInfoClass.
func ( *bin.Buffer) (HelpUserInfoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case HelpUserInfoEmptyTypeID:
		// Decoding help.userInfoEmpty#f3ae2eed.
		 := HelpUserInfoEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpUserInfoClass: %w", )
		}
		return &, nil
	case HelpUserInfoTypeID:
		// Decoding help.userInfo#1eb3758.
		 := HelpUserInfo{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpUserInfoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode HelpUserInfoClass: %w", bin.NewUnexpectedID())
	}
}

// HelpUserInfo boxes the HelpUserInfoClass providing a helper.
type HelpUserInfoBox struct {
	UserInfo HelpUserInfoClass
}

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

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