func (i Uint64Value) Type() ValueType {
	return Uint64ValueType
}
Type returns the type of the Value. It can be used to tell different ValueTypes apart and write polymorphic code.
package valuerange
import (
	"fmt"
	"strconv"
	"github.com/iotaledger/hive.go/cerrors"
	"github.com/iotaledger/hive.go/marshalutil"
	"golang.org/x/xerrors"
)
const (
	Int8ValueType ValueType = iota
	Int16ValueType
	Int32ValueType
	Int64ValueType
	Uint8ValueType
	Uint16ValueType
	Uint32ValueType
	Uint64ValueType
)
var ValueTypeNames = [...]string{
	"Int8ValueType",
	"Int16ValueType",
	"Int32ValueType",
	"Int64ValueType",
	"Uint8ValueType",
	"Uint16ValueType",
	"Uint32ValueType",
	"Uint64ValueType",
}
type ValueType int8
func ValueTypeFromBytes(valueTypeBytes []byte) (valueType ValueType, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(valueTypeBytes)
	if valueType, err = ValueTypeFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func ValueTypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (valueType ValueType, err error) {
	valueTypeByte, err := marshalUtil.ReadByte()
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	if valueType = ValueType(valueTypeByte); valueType > Uint64ValueType {
		err = xerrors.Errorf("unsupported ValueType (%X): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	return
}
func (v ValueType) Bytes() []byte {
	return []byte{byte(v)}
}
func (v ValueType) String() string {
	if int(v) >= len(ValueTypeNames) {
		return fmt.Sprintf("ValueType(%X)", uint8(v))
	}
	return ValueTypeNames[v]
}
type Value interface {
	Type() ValueType
	Compare(other Value) int
	Bytes() []byte
	String() string
}
func ValueFromBytes(valueBytes []byte) (value Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(valueBytes)
	if value, err = ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (value Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	marshalUtil.ReadSeek(-1)
	switch valueType {
	case Int8ValueType:
		if value, err = Int8ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Int8Value: %w", err)
			return
		}
	case Int16ValueType:
		if value, err = Int16ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Int16Value: %w", err)
			return
		}
	case Int32ValueType:
		if value, err = Int32ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Int32Value: %w", err)
			return
		}
	case Int64ValueType:
		if value, err = Int64ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Int64Value: %w", err)
			return
		}
	case Uint8ValueType:
		if value, err = Uint8ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Uint8Value: %w", err)
			return
		}
	case Uint16ValueType:
		if value, err = Uint16ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Uint16Value: %w", err)
			return
		}
	case Uint32ValueType:
		if value, err = Uint32ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Uint32Value: %w", err)
			return
		}
	case Uint64ValueType:
		if value, err = Uint64ValueFromMarshalUtil(marshalUtil); err != nil {
			err = xerrors.Errorf("failed to parse Uint64Value: %w", err)
			return
		}
	default:
		err = xerrors.Errorf("unsupported ValueType (%X): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	return
}
type Int8Value int8
func Int8ValueFromBytes(bytes []byte) (int8Value Int8Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if int8Value, err = Int8ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Int8Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Int8ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int8Value Int8Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Int8ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadInt8()
	if err != nil {
		err = xerrors.Errorf("failed to read int8 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	int8Value = Int8Value(value)
	return
}
func (i Int8Value) Type() ValueType {
	return Int8ValueType
}
func (i Int8Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Int8Value)
	if !typeCastOK {
		panic("can only compare an Int8Value to another Int8Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Int8Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Int8Size).
		Write(Int8ValueType).
		WriteInt8(int8(i)).
		Bytes()
}
func (i Int8Value) String() string {
	return "Int8Value(" + strconv.FormatInt(int64(i), 10) + ")"
}
var _ Value = Int8Value(0)
type Int16Value int16
func Int16ValueFromBytes(bytes []byte) (int16Value Int16Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if int16Value, err = Int16ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Int16Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Int16ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int16Value Int16Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Int16ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadInt16()
	if err != nil {
		err = xerrors.Errorf("failed to read int16 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	int16Value = Int16Value(value)
	return
}
func (i Int16Value) Type() ValueType {
	return Int16ValueType
}
func (i Int16Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Int16Value)
	if !typeCastOK {
		panic("can only compare an Int16Value to another Int16Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Int16Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Int16Size).
		Write(Int16ValueType).
		WriteInt16(int16(i)).
		Bytes()
}
func (i Int16Value) String() string {
	return "Int16Value(" + strconv.FormatInt(int64(i), 10) + ")"
}
var _ Value = Int16Value(0)
type Int32Value int32
func Int32ValueFromBytes(bytes []byte) (int32Value Int32Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if int32Value, err = Int32ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Int32Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Int32ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int32Value Int32Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Int32ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadInt32()
	if err != nil {
		err = xerrors.Errorf("failed to read int32 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	int32Value = Int32Value(value)
	return
}
func (i Int32Value) Type() ValueType {
	return Int32ValueType
}
func (i Int32Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Int32Value)
	if !typeCastOK {
		panic("can only compare an Int32Value to another Int32Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Int32Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Int32Size).
		Write(Int32ValueType).
		WriteInt32(int32(i)).
		Bytes()
}
func (i Int32Value) String() string {
	return "Int32Value(" + strconv.FormatInt(int64(i), 10) + ")"
}
var _ Value = Int32Value(0)
type Int64Value int64
func Int64ValueFromBytes(bytes []byte) (int64Value Int64Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if int64Value, err = Int64ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Int64Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Int64ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (int64Value Int64Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Int64ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadInt64()
	if err != nil {
		err = xerrors.Errorf("failed to read int64 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	int64Value = Int64Value(value)
	return
}
func (i Int64Value) Type() ValueType {
	return Int64ValueType
}
func (i Int64Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Int64Value)
	if !typeCastOK {
		panic("can only compare an Int64Value to another Int64Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Int64Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Int64Size).
		Write(Int64ValueType).
		WriteInt64(int64(i)).
		Bytes()
}
func (i Int64Value) String() string {
	return "Int64Value(" + strconv.FormatInt(int64(i), 10) + ")"
}
var _ Value = Int64Value(0)
type Uint8Value uint8
func Uint8ValueFromBytes(bytes []byte) (uint8Value Uint8Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if uint8Value, err = Uint8ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Uint8Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Uint8ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint8Value Uint8Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Uint8ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadUint8()
	if err != nil {
		err = xerrors.Errorf("failed to read uint8 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	uint8Value = Uint8Value(value)
	return
}
func (i Uint8Value) Type() ValueType {
	return Uint8ValueType
}
func (i Uint8Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Uint8Value)
	if !typeCastOK {
		panic("can only compare an Uint8Value to another Uint8Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Uint8Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Uint8Size).
		Write(Uint8ValueType).
		WriteUint8(uint8(i)).
		Bytes()
}
func (i Uint8Value) String() string {
	return "Uint8Value(" + strconv.FormatUint(uint64(i), 10) + ")"
}
var _ Value = Uint8Value(0)
type Uint16Value uint16
func Uint16ValueFromBytes(bytes []byte) (uint16Value Uint16Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if uint16Value, err = Uint16ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Uint16Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Uint16ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint16Value Uint16Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Uint16ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadUint16()
	if err != nil {
		err = xerrors.Errorf("failed to read uint16 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	uint16Value = Uint16Value(value)
	return
}
func (i Uint16Value) Type() ValueType {
	return Uint16ValueType
}
func (i Uint16Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Uint16Value)
	if !typeCastOK {
		panic("can only compare an Uint16Value to another Uint16Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Uint16Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Uint16Size).
		Write(Uint16ValueType).
		WriteUint16(uint16(i)).
		Bytes()
}
func (i Uint16Value) String() string {
	return "Uint16Value(" + strconv.FormatUint(uint64(i), 10) + ")"
}
var _ Value = Uint16Value(0)
type Uint32Value uint32
func Uint32ValueFromBytes(bytes []byte) (uint32Value Uint32Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if uint32Value, err = Uint32ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Uint32Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Uint32ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint32Value Uint32Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Uint32ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadUint32()
	if err != nil {
		err = xerrors.Errorf("failed to read uint32 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	uint32Value = Uint32Value(value)
	return
}
func (i Uint32Value) Type() ValueType {
	return Uint32ValueType
}
func (i Uint32Value) Compare(other Value) int {
	typeCastedOtherValue, typeCastOK := other.(Uint32Value)
	if !typeCastOK {
		panic("can only compare an Uint32Value to another Uint32Value")
	}
	if typeCastedOtherValue == i {
		return 0
	}
	if typeCastedOtherValue > i {
		return -1
	}
	return 1
}
func (i Uint32Value) Bytes() []byte {
	return marshalutil.New(1 + marshalutil.Uint32Size).
		Write(Uint32ValueType).
		WriteUint32(uint32(i)).
		Bytes()
}
func (i Uint32Value) String() string {
	return "Uint32Value(" + strconv.FormatUint(uint64(i), 10) + ")"
}
var _ Value = Uint32Value(0)
type Uint64Value uint64
func Uint64ValueFromBytes(bytes []byte) (uint64Value Uint64Value, consumedBytes int, err error) {
	marshalUtil := marshalutil.New(bytes)
	if uint64Value, err = Uint64ValueFromMarshalUtil(marshalUtil); err != nil {
		err = xerrors.Errorf("failed to parse Uint64Value from MarshalUtil: %w", err)
		return
	}
	consumedBytes = marshalUtil.ReadOffset()
	return
}
func Uint64ValueFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (uint64Value Uint64Value, err error) {
	valueType, err := ValueTypeFromMarshalUtil(marshalUtil)
	if err != nil {
		err = xerrors.Errorf("failed to parse ValueType from MarshalUtil: %w", err)
		return
	}
	if valueType != Uint64ValueType {
		err = xerrors.Errorf("invalid ValueType (%s): %w", valueType, cerrors.ErrParseBytesFailed)
		return
	}
	value, err := marshalUtil.ReadUint64()
	if err != nil {
		err = xerrors.Errorf("failed to read uint64 (%v): %w", err, cerrors.ErrParseBytesFailed)
		return
	}
	uint64Value = Uint64Value(value)
	return
}