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

// PremiumGiftCodeOptionVector is a box for Vector<PremiumGiftCodeOption>
type PremiumGiftCodeOptionVector struct {
	// Elements of Vector<PremiumGiftCodeOption>
	Elems []PremiumGiftCodeOption
}

// PremiumGiftCodeOptionVectorTypeID is TL type id of PremiumGiftCodeOptionVector.
const PremiumGiftCodeOptionVectorTypeID = bin.TypeVector

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

func ( *PremiumGiftCodeOptionVector) () bool {
	if  == nil {
		return true
	}
	if !(.Elems == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PremiumGiftCodeOptionVector from given interface.
func ( *PremiumGiftCodeOptionVector) ( interface {
	() ( []PremiumGiftCodeOption)
}) {
	.Elems = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *PremiumGiftCodeOptionVector) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode Vector<PremiumGiftCodeOption> as nil")
	}

	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumGiftCodeOptionVector) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode Vector<PremiumGiftCodeOption> as nil")
	}
	.PutVectorHeader(len(.Elems))
	for ,  := range .Elems {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode Vector<PremiumGiftCodeOption>: field Elems element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumGiftCodeOptionVector) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode Vector<PremiumGiftCodeOption> to nil")
	}

	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumGiftCodeOptionVector) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode Vector<PremiumGiftCodeOption> to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode Vector<PremiumGiftCodeOption>: field Elems: %w", )
		}

		if  > 0 {
			.Elems = make([]PremiumGiftCodeOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PremiumGiftCodeOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode Vector<PremiumGiftCodeOption>: field Elems: %w", )
			}
			.Elems = append(.Elems, )
		}
	}
	return nil
}

// GetElems returns value of Elems field.
func ( *PremiumGiftCodeOptionVector) () ( []PremiumGiftCodeOption) {
	if  == nil {
		return
	}
	return .Elems
}