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

// WalletTonConnectPending represents TL type `wallet.tonConnectPending#85c0f124`.
//
// See https://core.telegram.org/constructor/wallet.tonConnectPending for reference.
type WalletTonConnectPending struct {
	// Session field of WalletTonConnectPending.
	Session TonConnectSession
	// Requests field of WalletTonConnectPending.
	Requests []TonConnectRequest
}

// WalletTonConnectPendingTypeID is TL type id of WalletTonConnectPending.
const WalletTonConnectPendingTypeID = 0x85c0f124

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

func ( *WalletTonConnectPending) () bool {
	if  == nil {
		return true
	}
	if !(.Session.Zero()) {
		return false
	}
	if !(.Requests == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WalletTonConnectPending from given interface.
func ( *WalletTonConnectPending) ( interface {
	() ( TonConnectSession)
	() ( []TonConnectRequest)
}) {
	.Session = .()
	.Requests = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WalletTonConnectPending) () tdp.Type {
	 := tdp.Type{
		Name: "wallet.tonConnectPending",
		ID:   WalletTonConnectPendingTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Session",
			SchemaName: "session",
		},
		{
			Name:       "Requests",
			SchemaName: "requests",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *WalletTonConnectPending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.tonConnectPending#85c0f124 as nil")
	}
	.PutID(WalletTonConnectPendingTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WalletTonConnectPending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.tonConnectPending#85c0f124 as nil")
	}
	if  := .Session.Encode();  != nil {
		return fmt.Errorf("unable to encode wallet.tonConnectPending#85c0f124: field session: %w", )
	}
	.PutVectorHeader(len(.Requests))
	for ,  := range .Requests {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.tonConnectPending#85c0f124: field requests element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *WalletTonConnectPending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.tonConnectPending#85c0f124 to nil")
	}
	if  := .ConsumeID(WalletTonConnectPendingTypeID);  != nil {
		return fmt.Errorf("unable to decode wallet.tonConnectPending#85c0f124: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *WalletTonConnectPending) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.tonConnectPending#85c0f124 to nil")
	}
	{
		if  := .Session.Decode();  != nil {
			return fmt.Errorf("unable to decode wallet.tonConnectPending#85c0f124: field session: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.tonConnectPending#85c0f124: field requests: %w", )
		}

		if  > 0 {
			.Requests = make([]TonConnectRequest, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  TonConnectRequest
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode wallet.tonConnectPending#85c0f124: field requests: %w", )
			}
			.Requests = append(.Requests, )
		}
	}
	return nil
}

// GetSession returns value of Session field.
func ( *WalletTonConnectPending) () ( TonConnectSession) {
	if  == nil {
		return
	}
	return .Session
}

// GetRequests returns value of Requests field.
func ( *WalletTonConnectPending) () ( []TonConnectRequest) {
	if  == nil {
		return
	}
	return .Requests
}