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

// AttachMenuBotsNotModified represents TL type `attachMenuBotsNotModified#f1d88a5c`.
// The list of bot mini apps hasn't changed
//
// See https://core.telegram.org/constructor/attachMenuBotsNotModified for reference.
type AttachMenuBotsNotModified struct {
}

// AttachMenuBotsNotModifiedTypeID is TL type id of AttachMenuBotsNotModified.
const AttachMenuBotsNotModifiedTypeID = 0xf1d88a5c

// construct implements constructor of AttachMenuBotsClass.
func ( AttachMenuBotsNotModified) () AttachMenuBotsClass { return & }

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

	_ AttachMenuBotsClass = &AttachMenuBotsNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *AttachMenuBotsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBotsNotModified#f1d88a5c as nil")
	}
	.PutID(AttachMenuBotsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AttachMenuBotsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBotsNotModified#f1d88a5c as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AttachMenuBotsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode attachMenuBotsNotModified#f1d88a5c to nil")
	}
	return nil
}

// AttachMenuBots represents TL type `attachMenuBots#3c4301c0`.
// Represents a list of bot mini apps that can be launched from the attachment menu »¹
//
// Links:
//  1. https://core.telegram.org/api/bots/attach
//
// See https://core.telegram.org/constructor/attachMenuBots for reference.
type AttachMenuBots struct {
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// List of bot mini apps that can be launched from the attachment menu »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/attach
	Bots []AttachMenuBot
	// Info about related users/bots
	Users []UserClass
}

// AttachMenuBotsTypeID is TL type id of AttachMenuBots.
const AttachMenuBotsTypeID = 0x3c4301c0

// construct implements constructor of AttachMenuBotsClass.
func ( AttachMenuBots) () AttachMenuBotsClass { return & }

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

	_ AttachMenuBotsClass = &AttachMenuBots{}
)

func ( *AttachMenuBots) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Bots == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AttachMenuBots from given interface.
func ( *AttachMenuBots) ( interface {
	() ( int64)
	() ( []AttachMenuBot)
	() ( []UserClass)
}) {
	.Hash = .()
	.Bots = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AttachMenuBots) () tdp.Type {
	 := tdp.Type{
		Name: "attachMenuBots",
		ID:   AttachMenuBotsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Bots",
			SchemaName: "bots",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AttachMenuBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBots#3c4301c0 as nil")
	}
	.PutID(AttachMenuBotsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AttachMenuBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBots#3c4301c0 as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Bots))
	for ,  := range .Bots {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field bots element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode attachMenuBots#3c4301c0: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AttachMenuBots) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode attachMenuBots#3c4301c0 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field bots: %w", )
		}

		if  > 0 {
			.Bots = make([]AttachMenuBot, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AttachMenuBot
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field bots: %w", )
			}
			.Bots = append(.Bots, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBots#3c4301c0: field users: %w", )
		}

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

// GetHash returns value of Hash field.
func ( *AttachMenuBots) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// GetBots returns value of Bots field.
func ( *AttachMenuBots) () ( []AttachMenuBot) {
	if  == nil {
		return
	}
	return .Bots
}

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

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

// AttachMenuBotsClassName is schema name of AttachMenuBotsClass.
const AttachMenuBotsClassName = "AttachMenuBots"

// AttachMenuBotsClass represents AttachMenuBots generic type.
//
// See https://core.telegram.org/type/AttachMenuBots for reference.
//
// Example:
//
//	g, err := tg.DecodeAttachMenuBots(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AttachMenuBotsNotModified: // attachMenuBotsNotModified#f1d88a5c
//	case *tg.AttachMenuBots: // attachMenuBots#3c4301c0
//	default: panic(v)
//	}
type AttachMenuBotsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AttachMenuBotsClass

	// 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 AttachMenuBotsClass to AttachMenuBots.
	AsModified() (*AttachMenuBots, bool)
}

// AsModified tries to map AttachMenuBotsNotModified to AttachMenuBots.
func ( *AttachMenuBotsNotModified) () (*AttachMenuBots, bool) {
	return nil, false
}

// AsModified tries to map AttachMenuBots to AttachMenuBots.
func ( *AttachMenuBots) () (*AttachMenuBots, bool) {
	return , true
}

// DecodeAttachMenuBots implements binary de-serialization for AttachMenuBotsClass.
func ( *bin.Buffer) (AttachMenuBotsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AttachMenuBotsNotModifiedTypeID:
		// Decoding attachMenuBotsNotModified#f1d88a5c.
		 := AttachMenuBotsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", )
		}
		return &, nil
	case AttachMenuBotsTypeID:
		// Decoding attachMenuBots#3c4301c0.
		 := AttachMenuBots{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AttachMenuBotsClass: %w", bin.NewUnexpectedID())
	}
}

// AttachMenuBots boxes the AttachMenuBotsClass providing a helper.
type AttachMenuBotsBox struct {
	AttachMenuBots AttachMenuBotsClass
}

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

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