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

// ShareThemeBackdropsNotModified represents TL type `shareThemeBackdropsNotModified#7a3f6dff`.
//
// See https://core.telegram.org/constructor/shareThemeBackdropsNotModified for reference.
type ShareThemeBackdropsNotModified struct {
}

// ShareThemeBackdropsNotModifiedTypeID is TL type id of ShareThemeBackdropsNotModified.
const ShareThemeBackdropsNotModifiedTypeID = 0x7a3f6dff

// construct implements constructor of ShareThemeBackdropsClass.
func ( ShareThemeBackdropsNotModified) () ShareThemeBackdropsClass { return & }

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

	_ ShareThemeBackdropsClass = &ShareThemeBackdropsNotModified{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *ShareThemeBackdropsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode shareThemeBackdropsNotModified#7a3f6dff as nil")
	}
	.PutID(ShareThemeBackdropsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ShareThemeBackdropsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode shareThemeBackdropsNotModified#7a3f6dff as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ShareThemeBackdropsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode shareThemeBackdropsNotModified#7a3f6dff to nil")
	}
	return nil
}

// ShareThemeBackdrops represents TL type `shareThemeBackdrops#aaeadce0`.
//
// See https://core.telegram.org/constructor/shareThemeBackdrops for reference.
type ShareThemeBackdrops struct {
	// Hash field of ShareThemeBackdrops.
	Hash int
	// Backdrops field of ShareThemeBackdrops.
	Backdrops []ShareThemeBackdropOption
}

// ShareThemeBackdropsTypeID is TL type id of ShareThemeBackdrops.
const ShareThemeBackdropsTypeID = 0xaaeadce0

// construct implements constructor of ShareThemeBackdropsClass.
func ( ShareThemeBackdrops) () ShareThemeBackdropsClass { return & }

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

	_ ShareThemeBackdropsClass = &ShareThemeBackdrops{}
)

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

	return true
}

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

// FillFrom fills ShareThemeBackdrops from given interface.
func ( *ShareThemeBackdrops) ( interface {
	() ( int)
	() ( []ShareThemeBackdropOption)
}) {
	.Hash = .()
	.Backdrops = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ShareThemeBackdrops) () tdp.Type {
	 := tdp.Type{
		Name: "shareThemeBackdrops",
		ID:   ShareThemeBackdropsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Backdrops",
			SchemaName: "backdrops",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ShareThemeBackdrops) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode shareThemeBackdrops#aaeadce0 as nil")
	}
	.PutID(ShareThemeBackdropsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ShareThemeBackdrops) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode shareThemeBackdrops#aaeadce0 as nil")
	}
	.PutInt(.Hash)
	.PutVectorHeader(len(.Backdrops))
	for ,  := range .Backdrops {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode shareThemeBackdrops#aaeadce0: field backdrops element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ShareThemeBackdrops) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode shareThemeBackdrops#aaeadce0 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode shareThemeBackdrops#aaeadce0: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode shareThemeBackdrops#aaeadce0: field backdrops: %w", )
		}

		if  > 0 {
			.Backdrops = make([]ShareThemeBackdropOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ShareThemeBackdropOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode shareThemeBackdrops#aaeadce0: field backdrops: %w", )
			}
			.Backdrops = append(.Backdrops, )
		}
	}
	return nil
}

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

// GetBackdrops returns value of Backdrops field.
func ( *ShareThemeBackdrops) () ( []ShareThemeBackdropOption) {
	if  == nil {
		return
	}
	return .Backdrops
}

// ShareThemeBackdropsClassName is schema name of ShareThemeBackdropsClass.
const ShareThemeBackdropsClassName = "ShareThemeBackdrops"

// ShareThemeBackdropsClass represents ShareThemeBackdrops generic type.
//
// See https://core.telegram.org/type/ShareThemeBackdrops for reference.
//
// Constructors:
//   - [ShareThemeBackdropsNotModified]
//   - [ShareThemeBackdrops]
//
// Example:
//
//	g, err := tg.DecodeShareThemeBackdrops(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ShareThemeBackdropsNotModified: // shareThemeBackdropsNotModified#7a3f6dff
//	case *tg.ShareThemeBackdrops: // shareThemeBackdrops#aaeadce0
//	default: panic(v)
//	}
type ShareThemeBackdropsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ShareThemeBackdropsClass

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

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

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

// DecodeShareThemeBackdrops implements binary de-serialization for ShareThemeBackdropsClass.
func ( *bin.Buffer) (ShareThemeBackdropsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ShareThemeBackdropsNotModifiedTypeID:
		// Decoding shareThemeBackdropsNotModified#7a3f6dff.
		 := ShareThemeBackdropsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ShareThemeBackdropsClass: %w", )
		}
		return &, nil
	case ShareThemeBackdropsTypeID:
		// Decoding shareThemeBackdrops#aaeadce0.
		 := ShareThemeBackdrops{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ShareThemeBackdropsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ShareThemeBackdropsClass: %w", bin.NewUnexpectedID())
	}
}

// ShareThemeBackdrops boxes the ShareThemeBackdropsClass providing a helper.
type ShareThemeBackdropsBox struct {
	ShareThemeBackdrops ShareThemeBackdropsClass
}

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

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