Documentation ¶
Index ¶
- Variables
- type Array
- type Bool
- type Byte
- type Bytes
- type Call
- type CallChain
- type Double
- type Error
- type Float
- type IVariantCreator
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type Map
- func MakeReadonlyMapFromGoMap[K comparable, V any](m map[K]V) (Map, error)
- func MakeReadonlyMapFromSliceMap[K cmp.Ordered, V any](m generic.SliceMap[K, V]) (Map, error)
- func MakeReadonlyMapFromUnorderedSliceMap[K comparable, V any](m generic.UnorderedSliceMap[K, V]) (Map, error)
- func MakeSerializedMapFromGoMap[K comparable, V any](m map[K]V) (ret Map, err error)
- func MakeSerializedMapFromSliceMap[K cmp.Ordered, V any](m generic.SliceMap[K, V]) (ret Map, err error)
- func MakeSerializedMapFromUnorderedSliceMap[K comparable, V any](m generic.UnorderedSliceMap[K, V]) (ret Map, err error)
- type Null
- type SerializedValue
- type String
- type TypeId
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
- type Value
- type ValueReader
- type ValueWriter
- type Variant
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidCast = fmt.Errorf("%w: invalid cast", ErrVariant) // 类型转换错误
)
var (
ErrNotDeclared = fmt.Errorf("%w: variant not declared", ErrVariant) // 类型未注册
)
var (
ErrVariant = errors.New("gap-variant") // 可变类型错误
)
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array []Variant
Array array
func MakeReadonlyArray ¶ added in v0.2.17
MakeReadonlyArray 创建只读array
func MakeSerializedArray ¶ added in v0.2.17
MakeSerializedArray 创建已序列化array
type CallChain ¶ added in v0.1.69
type CallChain []Call
type IVariantCreator ¶
type IVariantCreator interface { // Declare 注册类型 Declare(v Value) // Undeclare 取消注册类型 Undeclare(typeId TypeId) // New 创建对象指针 New(typeId TypeId) (Value, error) // NewReflected 创建反射对象指针 NewReflected(typeId TypeId) (reflect.Value, error) }
IVariantCreator 可变类型对象构建器接口
type Map ¶
type Map generic.UnorderedSliceMap[Variant, Variant]
Map map
func MakeReadonlyMapFromGoMap ¶ added in v0.2.18
func MakeReadonlyMapFromGoMap[K comparable, V any](m map[K]V) (Map, error)
MakeReadonlyMapFromGoMap 创建只读map
func MakeReadonlyMapFromSliceMap ¶ added in v0.2.18
MakeReadonlyMapFromSliceMap 创建只读map
func MakeReadonlyMapFromUnorderedSliceMap ¶ added in v0.2.18
func MakeReadonlyMapFromUnorderedSliceMap[K comparable, V any](m generic.UnorderedSliceMap[K, V]) (Map, error)
MakeReadonlyMapFromUnorderedSliceMap 创建只读map
func MakeSerializedMapFromGoMap ¶ added in v0.2.18
func MakeSerializedMapFromGoMap[K comparable, V any](m map[K]V) (ret Map, err error)
MakeSerializedMapFromGoMap 创建已序列化map
func MakeSerializedMapFromSliceMap ¶ added in v0.2.18
func MakeSerializedMapFromSliceMap[K cmp.Ordered, V any](m generic.SliceMap[K, V]) (ret Map, err error)
MakeSerializedMapFromSliceMap 创建已序列化map
func MakeSerializedMapFromUnorderedSliceMap ¶ added in v0.2.18
func MakeSerializedMapFromUnorderedSliceMap[K comparable, V any](m generic.UnorderedSliceMap[K, V]) (ret Map, err error)
MakeSerializedMapFromUnorderedSliceMap 创建已序列化map
func (*Map) ToUnorderedSliceMap ¶ added in v0.1.96
func (v *Map) ToUnorderedSliceMap() *generic.UnorderedSliceMap[Variant, Variant]
ToUnorderedSliceMap 转换为UnorderedSliceMap
type SerializedValue ¶ added in v0.2.17
type SerializedValue struct { Type TypeId // 类型Id Data binaryutil.RecycleBytes // 数据 }
SerializedValue 已序列化值
func MakeSerializedValue ¶ added in v0.2.17
func MakeSerializedValue(v ValueReader) (ret *SerializedValue, err error)
MakeSerializedValue 创建已序列化值
func (*SerializedValue) Indirect ¶ added in v0.2.17
func (v *SerializedValue) Indirect() any
Indirect 原始值
func (*SerializedValue) Read ¶ added in v0.2.17
func (v *SerializedValue) Read(p []byte) (int, error)
Read implements io.Reader
func (*SerializedValue) TypeId ¶ added in v0.2.17
func (v *SerializedValue) TypeId() TypeId
TypeId 类型
type TypeId ¶
type TypeId uint32
TypeId 类型Id
const ( TypeId_None TypeId = iota TypeId_Int TypeId_Int8 TypeId_Int16 TypeId_Int32 TypeId_Int64 TypeId_Uint TypeId_Uint8 TypeId_Uint16 TypeId_Uint32 TypeId_Uint64 TypeId_Float TypeId_Double TypeId_Byte TypeId_Bool TypeId_Bytes TypeId_String TypeId_Null TypeId_Array TypeId_Map TypeId_Error TypeId_CallChain TypeId_Customize = 32 // 自定义类型起点 )
func (TypeId) NewReflected ¶
NewReflected 创建反射对象指针
type ValueReader ¶
type ValueReader interface { io.Reader // Size 大小 Size() int // TypeId 类型 TypeId() TypeId // Indirect 原始值 Indirect() any }
ValueReader 读取值
type ValueWriter ¶
ValueWriter 写入值
type Variant ¶
type Variant struct { TypeId TypeId // 类型Id Value Value // 值 Reflected reflect.Value // 反射值 ReadonlyValue ValueReader // 只读值 SerializedValue *SerializedValue // 已序列化值 }
Variant 可变类型
func CastReadonlyVariant ¶ added in v0.2.17
CastReadonlyVariant 转换只读可变类型
func CastSerializedVariant ¶ added in v0.2.17
CastSerializedVariant 转换已序列化可变类型
func MakeReadonlyVariant ¶ added in v0.2.17
func MakeReadonlyVariant(v ValueReader) (Variant, error)
MakeReadonlyVariant 创建只读可变类型
func MakeSerializedVariant ¶ added in v0.2.17
func MakeSerializedVariant(v ValueReader) (Variant, error)
MakeSerializedVariant 创建已序列化可变类型
Source Files ¶
- serializedvalue.go
- typeid.go
- typeid_builtin.go
- value.go
- value_builtin_array.go
- value_builtin_array_readonly.go
- value_builtin_array_serialized.go
- value_builtin_bool.go
- value_builtin_byte.go
- value_builtin_bytes.go
- value_builtin_callchain.go
- value_builtin_double.go
- value_builtin_error.go
- value_builtin_float.go
- value_builtin_int.go
- value_builtin_int16.go
- value_builtin_int32.go
- value_builtin_int64.go
- value_builtin_int8.go
- value_builtin_map.go
- value_builtin_map_readonly.go
- value_builtin_map_serialized.go
- value_builtin_null.go
- value_builtin_string.go
- value_builtin_uint.go
- value_builtin_uint16.go
- value_builtin_uint32.go
- value_builtin_uint64.go
- value_builtin_uint8.go
- variant.go
- variant_convert.go
- variant_readonly.go
- variant_readonly_cast.go
- variant_serialized.go
- variant_serialized_cast.go
- variantcreator.go