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
}
Int16ValueFromMarshalUtil unmarshals an Int16Value using a MarshalUtil (for easier unmarshaling).
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
}