go-p2p/node/levin/compat.go
Virgil cc0715785d fix(node): restore AX compatibility aliases
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 13:11:24 +00:00

87 lines
3.1 KiB
Go

// Copyright (c) 2024-2026 Lethean Contributors
// SPDX-License-Identifier: EUPL-1.2
// This file provides short-form aliases for Value constructors,
// matching the naming used in the spec documentation.
package levin
// Uint64Val creates a Value of TypeUint64. Short-form alias for Uint64Value.
//
// value := Uint64Val(42)
func Uint64Val(v uint64) Value { return Uint64Value(v) }
// Uint32Val creates a Value of TypeUint32. Short-form alias for Uint32Value.
//
// value := Uint32Val(42)
func Uint32Val(v uint32) Value { return Uint32Value(v) }
// Uint16Val creates a Value of TypeUint16. Short-form alias for Uint16Value.
//
// value := Uint16Val(42)
func Uint16Val(v uint16) Value { return Uint16Value(v) }
// Uint8Val creates a Value of TypeUint8. Short-form alias for Uint8Value.
//
// value := Uint8Val(42)
func Uint8Val(v uint8) Value { return Uint8Value(v) }
// Int64Val creates a Value of TypeInt64. Short-form alias for Int64Value.
//
// value := Int64Val(42)
func Int64Val(v int64) Value { return Int64Value(v) }
// Int32Val creates a Value of TypeInt32. Short-form alias for Int32Value.
//
// value := Int32Val(42)
func Int32Val(v int32) Value { return Int32Value(v) }
// Int16Val creates a Value of TypeInt16. Short-form alias for Int16Value.
//
// value := Int16Val(42)
func Int16Val(v int16) Value { return Int16Value(v) }
// Int8Val creates a Value of TypeInt8. Short-form alias for Int8Value.
//
// value := Int8Val(42)
func Int8Val(v int8) Value { return Int8Value(v) }
// BoolVal creates a Value of TypeBool. Short-form alias for BoolValue.
//
// value := BoolVal(true)
func BoolVal(v bool) Value { return BoolValue(v) }
// DoubleVal creates a Value of TypeDouble. Short-form alias for DoubleValue.
//
// value := DoubleVal(3.14)
func DoubleVal(v float64) Value { return DoubleValue(v) }
// StringVal creates a Value of TypeString. Short-form alias for StringValue.
//
// value := StringVal([]byte("hello"))
func StringVal(v []byte) Value { return StringValue(v) }
// ObjectVal creates a Value of TypeObject. Short-form alias for ObjectValue.
//
// value := ObjectVal(Section{"id": StringVal([]byte("peer-1"))})
func ObjectVal(s Section) Value { return ObjectValue(s) }
// Uint64ArrayVal creates a typed array of uint64 values. Short-form alias for Uint64ArrayValue.
//
// value := Uint64ArrayVal([]uint64{1, 2, 3})
func Uint64ArrayVal(vs []uint64) Value { return Uint64ArrayValue(vs) }
// Uint32ArrayVal creates a typed array of uint32 values. Short-form alias for Uint32ArrayValue.
//
// value := Uint32ArrayVal([]uint32{1, 2, 3})
func Uint32ArrayVal(vs []uint32) Value { return Uint32ArrayValue(vs) }
// StringArrayVal creates a typed array of byte-string values. Short-form alias for StringArrayValue.
//
// value := StringArrayVal([][]byte{[]byte("a"), []byte("b")})
func StringArrayVal(vs [][]byte) Value { return StringArrayValue(vs) }
// ObjectArrayVal creates a typed array of Section values. Short-form alias for ObjectArrayValue.
//
// value := ObjectArrayVal([]Section{{"id": StringVal([]byte("peer-1"))}})
func ObjectArrayVal(vs []Section) Value { return ObjectArrayValue(vs) }