github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/exttinygo/interface.go (about)

     1  /*
     2  * Copyright (c) 2023-present unTill Pro, Ltd.
     3  *  @author Michael Saigachenko
     4   */
     5  
     6  package exttinygo
     7  
     8  import (
     9  	safe "github.com/voedger/voedger/pkg/state/isafestateapi"
    10  )
    11  
    12  type TKeyBuilder safe.TKeyBuilder
    13  type TIntent safe.TIntent
    14  type TValue safe.TValue
    15  type TKey safe.TKey
    16  type QName safe.QName
    17  
    18  var KeyBuilder func(storage, entity string) (b TKeyBuilder) = keyBuilderImpl
    19  
    20  // QueryValue queries value. When not exists it returns exists=false and value=nil.
    21  var QueryValue func(key TKeyBuilder) (value TValue, exists bool) = queryValueImpl
    22  
    23  // MustGetValue gets value. Panics when value is not exist
    24  var MustGetValue func(key TKeyBuilder) TValue = mustGetValueImpl
    25  
    26  // ReadValues reads using partial key and returns values in callback.
    27  //
    28  // Important: key and value are not kept after callback!
    29  var ReadValues func(key TKeyBuilder, callback func(key TKey, value TValue)) = readValuesImpl
    30  
    31  // UpdateValue creates intent to update a value
    32  var UpdateValue func(key TKeyBuilder, existingValue TValue) TIntent = updateValueImpl
    33  
    34  // NewValue creates intent for new value
    35  var NewValue func(key TKeyBuilder) TIntent = newValueImpl
    36  
    37  /*
    38  type IKey interface {
    39  	AsString(name string) string
    40  	AsInt32(name string) int32
    41  	AsInt64(name string) int64
    42  	AsFloat32(name string) float32
    43  	AsFloat64(name string) float64
    44  	AsBytes(name string) []byte
    45  	AsQName(name string) QName
    46  	AsBool(name string) bool
    47  }
    48  
    49  type IValue interface {
    50  	Len() int
    51  
    52  	AsString(name string) string
    53  	AsBytes(name string) []byte
    54  	AsInt32(name string) int32
    55  	AsInt64(name string) int64
    56  	AsFloat32(name string) float32
    57  	AsFloat64(name string) float64
    58  	AsQName(name string) QName
    59  	AsBool(name string) bool
    60  	AsValue(name string) IValue // throws panic if field is not an object or array
    61  
    62  	GetAsString(index int) string
    63  	GetAsBytes(index int) []byte
    64  	GetAsInt32(index int) int32
    65  	GetAsInt64(index int) int64
    66  	GetAsFloat32(index int) float32
    67  	GetAsFloat64(index int) float64
    68  	GetAsQName(index int) QName
    69  	GetAsBool(index int) bool
    70  	GetAsValue(index int) IValue // throws panic if field is not an object or array
    71  }
    72  
    73  type IRowWriter interface {
    74  	PutInt32(name string, value int32)
    75  	PutInt64(name string, value int64)
    76  	PutFloat32(name string, value float32)
    77  	PutFloat64(name string, value float64)
    78  	PutString(name string, value string)
    79  	PutBytes(name string, value []byte)
    80  	PutQName(name string, value QName)
    81  	PutBool(name string, value bool)
    82  }
    83  
    84  type IKeyBuilder interface {
    85  	IRowWriter
    86  }
    87  
    88  type IIntent interface {
    89  	IRowWriter
    90  }
    91  */