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

// AccountWallPapersNotModified represents TL type `account.wallPapersNotModified#1c199183`.
// No new wallpapers¹ were found
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/constructor/account.wallPapersNotModified for reference.
type AccountWallPapersNotModified struct {
}

// AccountWallPapersNotModifiedTypeID is TL type id of AccountWallPapersNotModified.
const AccountWallPapersNotModifiedTypeID = 0x1c199183

// construct implements constructor of AccountWallPapersClass.
func ( AccountWallPapersNotModified) () AccountWallPapersClass { return & }

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

	_ AccountWallPapersClass = &AccountWallPapersNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AccountWallPapersNotModified) () string {
	return "account.wallPapersNotModified"
}

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

// Encode implements bin.Encoder.
func ( *AccountWallPapersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.wallPapersNotModified#1c199183 as nil")
	}
	.PutID(AccountWallPapersNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountWallPapersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.wallPapersNotModified#1c199183 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountWallPapersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.wallPapersNotModified#1c199183 to nil")
	}
	if  := .ConsumeID(AccountWallPapersNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode account.wallPapersNotModified#1c199183: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountWallPapersNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.wallPapersNotModified#1c199183 to nil")
	}
	return nil
}

// AccountWallPapers represents TL type `account.wallPapers#cdc3858c`.
// Installed wallpapers¹
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/constructor/account.wallPapers for reference.
type AccountWallPapers struct {
	// Hash for pagination, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// Wallpapers¹
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	Wallpapers []WallPaperClass
}

// AccountWallPapersTypeID is TL type id of AccountWallPapers.
const AccountWallPapersTypeID = 0xcdc3858c

// construct implements constructor of AccountWallPapersClass.
func ( AccountWallPapers) () AccountWallPapersClass { return & }

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

	_ AccountWallPapersClass = &AccountWallPapers{}
)

func ( *AccountWallPapers) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Wallpapers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountWallPapers from given interface.
func ( *AccountWallPapers) ( interface {
	() ( int64)
	() ( []WallPaperClass)
}) {
	.Hash = .()
	.Wallpapers = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountWallPapers) () string {
	return "account.wallPapers"
}

// TypeInfo returns info about TL type.
func ( *AccountWallPapers) () tdp.Type {
	 := tdp.Type{
		Name: "account.wallPapers",
		ID:   AccountWallPapersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Wallpapers",
			SchemaName: "wallpapers",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountWallPapers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.wallPapers#cdc3858c as nil")
	}
	.PutID(AccountWallPapersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountWallPapers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.wallPapers#cdc3858c as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Wallpapers))
	for ,  := range .Wallpapers {
		if  == nil {
			return fmt.Errorf("unable to encode account.wallPapers#cdc3858c: field wallpapers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.wallPapers#cdc3858c: field wallpapers element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountWallPapers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.wallPapers#cdc3858c to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.wallPapers#cdc3858c: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.wallPapers#cdc3858c: field wallpapers: %w", )
		}

		if  > 0 {
			.Wallpapers = make([]WallPaperClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeWallPaper()
			if  != nil {
				return fmt.Errorf("unable to decode account.wallPapers#cdc3858c: field wallpapers: %w", )
			}
			.Wallpapers = append(.Wallpapers, )
		}
	}
	return nil
}

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

// GetWallpapers returns value of Wallpapers field.
func ( *AccountWallPapers) () ( []WallPaperClass) {
	if  == nil {
		return
	}
	return .Wallpapers
}

// MapWallpapers returns field Wallpapers wrapped in WallPaperClassArray helper.
func ( *AccountWallPapers) () ( WallPaperClassArray) {
	return WallPaperClassArray(.Wallpapers)
}

// AccountWallPapersClassName is schema name of AccountWallPapersClass.
const AccountWallPapersClassName = "account.WallPapers"

// AccountWallPapersClass represents account.WallPapers generic type.
//
// See https://core.telegram.org/type/account.WallPapers for reference.
//
// Example:
//
//	g, err := tg.DecodeAccountWallPapers(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountWallPapersNotModified: // account.wallPapersNotModified#1c199183
//	case *tg.AccountWallPapers: // account.wallPapers#cdc3858c
//	default: panic(v)
//	}
type AccountWallPapersClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountWallPapersClass

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

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

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

// DecodeAccountWallPapers implements binary de-serialization for AccountWallPapersClass.
func ( *bin.Buffer) (AccountWallPapersClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountWallPapersNotModifiedTypeID:
		// Decoding account.wallPapersNotModified#1c199183.
		 := AccountWallPapersNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountWallPapersClass: %w", )
		}
		return &, nil
	case AccountWallPapersTypeID:
		// Decoding account.wallPapers#cdc3858c.
		 := AccountWallPapers{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountWallPapersClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountWallPapersClass: %w", bin.NewUnexpectedID())
	}
}

// AccountWallPapers boxes the AccountWallPapersClass providing a helper.
type AccountWallPapersBox struct {
	WallPapers AccountWallPapersClass
}

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

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