func (StringValue) valueType() valueType {
	return stringValueType
}
valueType returns the EventStream header value type value.
package eventstream
import (
	"encoding/base64"
	"encoding/binary"
	"fmt"
	"io"
	"strconv"
	"time"
)
const maxHeaderValueLen = 1<<15 - 1  
type valueType uint8
const (
	trueValueType valueType = iota
	falseValueType
	int8ValueType   
	int16ValueType  
	int32ValueType  
	int64ValueType  
	bytesValueType
	stringValueType
	timestampValueType
	uuidValueType
)
func (t valueType) String() string {
	switch t {
	case trueValueType:
		return "bool"
	case falseValueType:
		return "bool"
	case int8ValueType:
		return "int8"
	case int16ValueType:
		return "int16"
	case int32ValueType:
		return "int32"
	case int64ValueType:
		return "int64"
	case bytesValueType:
		return "byte_array"
	case stringValueType:
		return "string"
	case timestampValueType:
		return "timestamp"
	case uuidValueType:
		return "uuid"
	default:
		return fmt.Sprintf("unknown value type %d", uint8(t))
	}
}
type rawValue struct {
	Type  valueType
	Len   uint16  
	Value []byte  
}
func (r rawValue) encodeScalar(w io.Writer, v interface{}) error {
	return binaryWriteFields(w, binary.BigEndian,
		r.Type,
		v,
	)
}
func (r rawValue) encodeFixedSlice(w io.Writer, v []byte) error {
	binary.Write(w, binary.BigEndian, r.Type)
	_, err := w.Write(v)
	return err
}
func (r rawValue) encodeBytes(w io.Writer, v []byte) error {
	if len(v) > maxHeaderValueLen {
		return LengthError{
			Part: "header value",
			Want: maxHeaderValueLen, Have: len(v),
			Value: v,
		}
	}
	r.Len = uint16(len(v))
	err := binaryWriteFields(w, binary.BigEndian,
		r.Type,
		r.Len,
	)
	if err != nil {
		return err
	}
	_, err = w.Write(v)
	return err
}
func (r rawValue) encodeString(w io.Writer, v string) error {
	if len(v) > maxHeaderValueLen {
		return LengthError{
			Part: "header value",
			Want: maxHeaderValueLen, Have: len(v),
			Value: v,
		}
	}
	r.Len = uint16(len(v))
	type stringWriter interface {
		WriteString(string) (int, error)
	}
	err := binaryWriteFields(w, binary.BigEndian,
		r.Type,
		r.Len,
	)
	if err != nil {
		return err
	}
	if sw, ok := w.(stringWriter); ok {
		_, err = sw.WriteString(v)
	} else {
		_, err = w.Write([]byte(v))
	}
	return err
}
func decodeFixedBytesValue(r io.Reader, buf []byte) error {
	_, err := io.ReadFull(r, buf)
	return err
}
func decodeBytesValue(r io.Reader) ([]byte, error) {
	var raw rawValue
	var err error
	raw.Len, err = decodeUint16(r)
	if err != nil {
		return nil, err
	}
	buf := make([]byte, raw.Len)
	_, err = io.ReadFull(r, buf)
	if err != nil {
		return nil, err
	}
	return buf, nil
}
func decodeStringValue(r io.Reader) (string, error) {
	v, err := decodeBytesValue(r)
	return string(v), err
}
type Value interface {
	Get() interface{}
	String() string
	valueType() valueType
	encode(io.Writer) error
}
type BoolValue bool
func (v BoolValue) Get() interface{} {
	return bool(v)
}
func (v BoolValue) valueType() valueType {
	if v {
		return trueValueType
	}
	return falseValueType
}
func (v BoolValue) String() string {
	return strconv.FormatBool(bool(v))
}
func (v BoolValue) encode(w io.Writer) error {
	return binary.Write(w, binary.BigEndian, v.valueType())
}
type Int8Value int8
func (v Int8Value) Get() interface{} {
	return int8(v)
}
func (Int8Value) valueType() valueType {
	return int8ValueType
}
func (v Int8Value) String() string {
	return fmt.Sprintf("0x%02x", int8(v))
}
func (v Int8Value) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeScalar(w, v)
}
func (v *Int8Value) decode(r io.Reader) error {
	n, err := decodeUint8(r)
	if err != nil {
		return err
	}
	*v = Int8Value(n)
	return nil
}
type Int16Value int16
func (v Int16Value) Get() interface{} {
	return int16(v)
}
func (Int16Value) valueType() valueType {
	return int16ValueType
}
func (v Int16Value) String() string {
	return fmt.Sprintf("0x%04x", int16(v))
}
func (v Int16Value) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeScalar(w, v)
}
func (v *Int16Value) decode(r io.Reader) error {
	n, err := decodeUint16(r)
	if err != nil {
		return err
	}
	*v = Int16Value(n)
	return nil
}
type Int32Value int32
func (v Int32Value) Get() interface{} {
	return int32(v)
}
func (Int32Value) valueType() valueType {
	return int32ValueType
}
func (v Int32Value) String() string {
	return fmt.Sprintf("0x%08x", int32(v))
}
func (v Int32Value) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeScalar(w, v)
}
func (v *Int32Value) decode(r io.Reader) error {
	n, err := decodeUint32(r)
	if err != nil {
		return err
	}
	*v = Int32Value(n)
	return nil
}
type Int64Value int64
func (v Int64Value) Get() interface{} {
	return int64(v)
}
func (Int64Value) valueType() valueType {
	return int64ValueType
}
func (v Int64Value) String() string {
	return fmt.Sprintf("0x%016x", int64(v))
}
func (v Int64Value) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeScalar(w, v)
}
func (v *Int64Value) decode(r io.Reader) error {
	n, err := decodeUint64(r)
	if err != nil {
		return err
	}
	*v = Int64Value(n)
	return nil
}
type BytesValue []byte
func (v BytesValue) Get() interface{} {
	return []byte(v)
}
func (BytesValue) valueType() valueType {
	return bytesValueType
}
func (v BytesValue) String() string {
	return base64.StdEncoding.EncodeToString([]byte(v))
}
func (v BytesValue) encode(w io.Writer) error {
	raw := rawValue{
		Type: v.valueType(),
	}
	return raw.encodeBytes(w, []byte(v))
}
func (v *BytesValue) decode(r io.Reader) error {
	buf, err := decodeBytesValue(r)
	if err != nil {
		return err
	}
	*v = BytesValue(buf)
	return nil
}
type StringValue string
func (v StringValue) Get() interface{} {
	return string(v)
}