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

// WalletTonConnectSessions represents TL type `wallet.tonConnectSessions#e1f6896`.
//
// See https://core.telegram.org/constructor/wallet.tonConnectSessions for reference.
type WalletTonConnectSessions struct {
	// Sessions field of WalletTonConnectSessions.
	Sessions []TonConnectSession
}

// WalletTonConnectSessionsTypeID is TL type id of WalletTonConnectSessions.
const WalletTonConnectSessionsTypeID = 0xe1f6896

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

func ( *WalletTonConnectSessions) () bool {
	if  == nil {
		return true
	}
	if !(.Sessions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WalletTonConnectSessions from given interface.
func ( *WalletTonConnectSessions) ( interface {
	() ( []TonConnectSession)
}) {
	.Sessions = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WalletTonConnectSessions) () tdp.Type {
	 := tdp.Type{
		Name: "wallet.tonConnectSessions",
		ID:   WalletTonConnectSessionsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Sessions",
			SchemaName: "sessions",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *WalletTonConnectSessions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.tonConnectSessions#e1f6896 as nil")
	}
	.PutID(WalletTonConnectSessionsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WalletTonConnectSessions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.tonConnectSessions#e1f6896 as nil")
	}
	.PutVectorHeader(len(.Sessions))
	for ,  := range .Sessions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.tonConnectSessions#e1f6896: field sessions element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WalletTonConnectSessions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.tonConnectSessions#e1f6896 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.tonConnectSessions#e1f6896: field sessions: %w", )
		}

		if  > 0 {
			.Sessions = make([]TonConnectSession, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  TonConnectSession
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode wallet.tonConnectSessions#e1f6896: field sessions: %w", )
			}
			.Sessions = append(.Sessions, )
		}
	}
	return nil
}

// GetSessions returns value of Sessions field.
func ( *WalletTonConnectSessions) () ( []TonConnectSession) {
	if  == nil {
		return
	}
	return .Sessions
}