func (m *Reader) ReadUint8() (u uint8, err error) {
	var in uint64
	in, err = m.ReadUint64()
	if in > math.MaxUint8 {
		err = UintOverflow{Value: in, FailedBitsize: 8}
		return
	}
	u = uint8(in)
	return
}
ReadUint8 reads a uint8 from the reader
package msgp
import (
	"io"
	"math"
	"sync"
	"time"
	"github.com/gofiber/fiber/v2/internal/fwd"
)
var readerPool = sync.Pool{New: func() interface{} { return &Reader{} }}
type Type byte
const (
	InvalidType Type = iota
	StrType
	BinType
	MapType
	ArrayType
	Float64Type
	Float32Type
	BoolType
	IntType
	UintType
	NilType
	ExtensionType
	Complex64Type
	Complex128Type
	TimeType
	_maxtype
)
func (t Type) String() string {
	switch t {
	case StrType:
		return "str"
	case BinType:
		return "bin"
	case MapType:
		return "map"
	case ArrayType:
		return "array"
	case Float64Type:
		return "float64"
	case Float32Type:
		return "float32"
	case BoolType:
		return "bool"
	case UintType:
		return "uint"
	case IntType:
		return "int"
	case ExtensionType:
		return "ext"
	case NilType:
		return "nil"
	default:
		return "<invalid>"
	}
}
func freeR(m *Reader) {
	readerPool.Put(m)
}
type Unmarshaler interface {
	UnmarshalMsg([]byte) ([]byte, error)
}
type Decodable interface {
	DecodeMsg(*Reader) error
}
func Decode(r io.Reader, d Decodable) error {
	rd := NewReader(r)
	err := d.DecodeMsg(rd)
	freeR(rd)
	return err
}
func NewReader(r io.Reader) *Reader {
	p := readerPool.Get().(*Reader)
	if p.R == nil {
		p.R = fwd.NewReader(r)
	} else {
		p.R.Reset(r)
	}
	return p
}
func NewReaderSize(r io.Reader, sz int) *Reader {
	return &Reader{R: fwd.NewReaderSize(r, sz)}
}
func NewReaderBuf(r io.Reader, buf []byte) *Reader {
	return &Reader{R: fwd.NewReaderBuf(r, buf)}
}
type Reader struct {
	R       *fwd.Reader
	scratch []byte
}
func (m *Reader) Read(p []byte) (int, error) {
	return m.R.Read(p)
}
func (m *Reader) CopyNext(w io.Writer) (int64, error) {
	sz, o, err := getNextSize(m.R)
	if err != nil {
		return 0, err
	}
	var n int64
	if int(sz) <= m.R.BufferSize() {
		var nn int
		var buf []byte
		buf, err = m.R.Next(int(sz))
		if err != nil {
			if err == io.ErrUnexpectedEOF {
				err = ErrShortBytes
			}
			return 0, err
		}
		nn, err = w.Write(buf)
		n += int64(nn)
	} else {
		n, err = io.CopyN(w, m.R, int64(sz))
		if err == io.ErrUnexpectedEOF {
			err = ErrShortBytes
		}
	}
	if err != nil {
		return n, err
	} else if n < int64(sz) {
		return n, io.ErrShortWrite
	}
	for x := uintptr(0); x < o; x++ {
		var n2 int64
		n2, err = m.CopyNext(w)
		if err != nil {
			return n, err
		}
		n += n2
	}
	return n, nil
}
func (m *Reader) ReadFull(p []byte) (int, error) {
	return m.R.ReadFull(p)
}
func (m *Reader) Reset(r io.Reader) { m.R.Reset(r) }
func (m *Reader) Buffered() int { return m.R.Buffered() }
func (m *Reader) BufferSize() int { return m.R.BufferSize() }
func (m *Reader) NextType() (Type, error) {
	p, err := m.R.Peek(1)
	if err != nil {
		return InvalidType, err
	}
	t := getType(p[0])
	if t == InvalidType {
		return t, InvalidPrefixError(p[0])
	}
	if t == ExtensionType {
		v, err := m.peekExtensionType()
		if err != nil {
			return InvalidType, err
		}
		switch v {
		case Complex64Extension:
			return Complex64Type, nil
		case Complex128Extension:
			return Complex128Type, nil
		case TimeExtension:
			return TimeType, nil
		}
	}
	return t, nil
}
func (m *Reader) IsNil() bool {
	p, err := m.R.Peek(1)
	return err == nil && p[0] == mnil
}
func getNextSize(r *fwd.Reader) (uintptr, uintptr, error) {
	b, err := r.Peek(1)
	if err != nil {
		return 0, 0, err
	}
	lead := b[0]
	spec := &sizes[lead]
	size, mode := spec.size, spec.extra
	if size == 0 {
		return 0, 0, InvalidPrefixError(lead)
	}
	if mode >= 0 {
		return uintptr(size), uintptr(mode), nil
	}
	b, err = r.Peek(int(size))
	if err != nil {
		return 0, 0, err
	}
	switch mode {
	case extra8:
		return uintptr(size) + uintptr(b[1]), 0, nil
	case extra16:
		return uintptr(size) + uintptr(big.Uint16(b[1:])), 0, nil
	case extra32:
		return uintptr(size) + uintptr(big.Uint32(b[1:])), 0, nil
	case map16v:
		return uintptr(size), 2 * uintptr(big.Uint16(b[1:])), nil
	case map32v:
		return uintptr(size), 2 * uintptr(big.Uint32(b[1:])), nil
	case array16v:
		return uintptr(size), uintptr(big.Uint16(b[1:])), nil
	case array32v:
		return uintptr(size), uintptr(big.Uint32(b[1:])), nil
	default:
		return 0, 0, fatal
	}
}
func (m *Reader) Skip() error {
	var (
		v   uintptr  
		o   uintptr  
		err error
		p   []byte
	)
	if m.R.Buffered() >= 5 {
		p, err = m.R.Peek(5)
		if err != nil {
			return err
		}
		v, o, err = getSize(p)
		if err != nil {
			return err
		}
	} else {
		v, o, err = getNextSize(m.R)
		if err != nil {
			return err
		}
	}
	_, err = m.R.Skip(int(v))
	if err != nil {
		return err
	}
	for x := uintptr(0); x < o; x++ {
		err = m.Skip()
		if err != nil {
			return err
		}
	}
	return nil
}
func (m *Reader) ReadMapHeader() (sz uint32, err error) {
	var p []byte
	var lead byte
	p, err = m.R.Peek(1)
	if err != nil {
		return
	}
	lead = p[0]
	if isfixmap(lead) {
		sz = uint32(rfixmap(lead))
		_, err = m.R.Skip(1)
		return
	}
	switch lead {
	case mmap16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		sz = uint32(big.Uint16(p[1:]))
		return
	case mmap32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		sz = big.Uint32(p[1:])
		return
	default:
		err = badPrefix(MapType, lead)
		return
	}
}
func (m *Reader) ReadMapKey(scratch []byte) ([]byte, error) {
	out, err := m.ReadStringAsBytes(scratch)
	if err != nil {
		if tperr, ok := err.(TypeError); ok && tperr.Encoded == BinType {
			return m.ReadBytes(scratch)
		}
		return nil, err
	}
	return out, nil
}
func (m *Reader) ReadMapKeyPtr() ([]byte, error) {
	p, err := m.R.Peek(1)
	if err != nil {
		return nil, err
	}
	lead := p[0]
	var read int
	if isfixstr(lead) {
		read = int(rfixstr(lead))
		m.R.Skip(1)
		goto fill
	}
	switch lead {
	case mstr8, mbin8:
		p, err = m.R.Next(2)
		if err != nil {
			return nil, err
		}
		read = int(p[1])
	case mstr16, mbin16:
		p, err = m.R.Next(3)
		if err != nil {
			return nil, err
		}
		read = int(big.Uint16(p[1:]))
	case mstr32, mbin32:
		p, err = m.R.Next(5)
		if err != nil {
			return nil, err
		}
		read = int(big.Uint32(p[1:]))
	default:
		return nil, badPrefix(StrType, lead)
	}
fill:
	if read == 0 {
		return nil, ErrShortBytes
	}
	return m.R.Next(read)
}
func (m *Reader) ReadArrayHeader() (sz uint32, err error) {
	var lead byte
	var p []byte
	p, err = m.R.Peek(1)
	if err != nil {
		return
	}
	lead = p[0]
	if isfixarray(lead) {
		sz = uint32(rfixarray(lead))
		_, err = m.R.Skip(1)
		return
	}
	switch lead {
	case marray16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		sz = uint32(big.Uint16(p[1:]))
		return
	case marray32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		sz = big.Uint32(p[1:])
		return
	default:
		err = badPrefix(ArrayType, lead)
		return
	}
}
func (m *Reader) ReadNil() error {
	p, err := m.R.Peek(1)
	if err != nil {
		return err
	}
	if p[0] != mnil {
		return badPrefix(NilType, p[0])
	}
	_, err = m.R.Skip(1)
	return err
}
func (m *Reader) ReadFloat64() (f float64, err error) {
	var p []byte
	p, err = m.R.Peek(9)
	if err != nil {
		if err == io.EOF && len(p) > 0 && p[0] == mfloat32 {
			ef, err := m.ReadFloat32()
			return float64(ef), err
		}
		return
	}
	if p[0] != mfloat64 {
		if p[0] == mfloat32 {
			ef, err := m.ReadFloat32()
			return float64(ef), err
		}
		err = badPrefix(Float64Type, p[0])
		return
	}
	f = math.Float64frombits(getMuint64(p))
	_, err = m.R.Skip(9)
	return
}
func (m *Reader) ReadFloat32() (f float32, err error) {
	var p []byte
	p, err = m.R.Peek(5)
	if err != nil {
		return
	}
	if p[0] != mfloat32 {
		err = badPrefix(Float32Type, p[0])
		return
	}
	f = math.Float32frombits(getMuint32(p))
	_, err = m.R.Skip(5)
	return
}
func (m *Reader) ReadBool() (b bool, err error) {
	var p []byte
	p, err = m.R.Peek(1)
	if err != nil {
		return
	}
	switch p[0] {
	case mtrue:
		b = true
	case mfalse:
	default:
		err = badPrefix(BoolType, p[0])
		return
	}
	_, err = m.R.Skip(1)
	return
}
func (m *Reader) ReadInt64() (i int64, err error) {
	var p []byte
	var lead byte
	p, err = m.R.Peek(1)
	if err != nil {
		return
	}
	lead = p[0]
	if isfixint(lead) {
		i = int64(rfixint(lead))
		_, err = m.R.Skip(1)
		return
	} else if isnfixint(lead) {
		i = int64(rnfixint(lead))
		_, err = m.R.Skip(1)
		return
	}
	switch lead {
	case mint8:
		p, err = m.R.Next(2)
		if err != nil {
			return
		}
		i = int64(getMint8(p))
		return
	case muint8:
		p, err = m.R.Next(2)
		if err != nil {
			return
		}
		i = int64(getMuint8(p))
		return
	case mint16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		i = int64(getMint16(p))
		return
	case muint16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		i = int64(getMuint16(p))
		return
	case mint32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		i = int64(getMint32(p))
		return
	case muint32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		i = int64(getMuint32(p))
		return
	case mint64:
		p, err = m.R.Next(9)
		if err != nil {
			return
		}
		i = getMint64(p)
		return
	case muint64:
		p, err = m.R.Next(9)
		if err != nil {
			return
		}
		u := getMuint64(p)
		if u > math.MaxInt64 {
			err = UintOverflow{Value: u, FailedBitsize: 64}
			return
		}
		i = int64(u)
		return
	default:
		err = badPrefix(IntType, lead)
		return
	}
}
func (m *Reader) ReadInt32() (i int32, err error) {
	var in int64
	in, err = m.ReadInt64()
	if in > math.MaxInt32 || in < math.MinInt32 {
		err = IntOverflow{Value: in, FailedBitsize: 32}
		return
	}
	i = int32(in)
	return
}
func (m *Reader) ReadInt16() (i int16, err error) {
	var in int64
	in, err = m.ReadInt64()
	if in > math.MaxInt16 || in < math.MinInt16 {
		err = IntOverflow{Value: in, FailedBitsize: 16}
		return
	}
	i = int16(in)
	return
}
func (m *Reader) ReadInt8() (i int8, err error) {
	var in int64
	in, err = m.ReadInt64()
	if in > math.MaxInt8 || in < math.MinInt8 {
		err = IntOverflow{Value: in, FailedBitsize: 8}
		return
	}
	i = int8(in)
	return
}
func (m *Reader) ReadInt() (i int, err error) {
	if smallint {
		var in int32
		in, err = m.ReadInt32()
		i = int(in)
		return
	}
	var in int64
	in, err = m.ReadInt64()
	i = int(in)
	return
}
func (m *Reader) ReadUint64() (u uint64, err error) {
	var p []byte
	var lead byte
	p, err = m.R.Peek(1)
	if err != nil {
		return
	}
	lead = p[0]
	if isfixint(lead) {
		u = uint64(rfixint(lead))
		_, err = m.R.Skip(1)
		return
	}
	switch lead {
	case mint8:
		p, err = m.R.Next(2)
		if err != nil {
			return
		}
		v := int64(getMint8(p))
		if v < 0 {
			err = UintBelowZero{Value: v}
			return
		}
		u = uint64(v)
		return
	case muint8:
		p, err = m.R.Next(2)
		if err != nil {
			return
		}
		u = uint64(getMuint8(p))
		return
	case mint16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		v := int64(getMint16(p))
		if v < 0 {
			err = UintBelowZero{Value: v}
			return
		}
		u = uint64(v)
		return
	case muint16:
		p, err = m.R.Next(3)
		if err != nil {
			return
		}
		u = uint64(getMuint16(p))
		return
	case mint32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		v := int64(getMint32(p))
		if v < 0 {
			err = UintBelowZero{Value: v}
			return
		}
		u = uint64(v)
		return
	case muint32:
		p, err = m.R.Next(5)
		if err != nil {
			return
		}
		u = uint64(getMuint32(p))
		return
	case mint64:
		p, err = m.R.Next(9)
		if err != nil {
			return
		}
		v := int64(getMint64(p))
		if v < 0 {
			err = UintBelowZero{Value: v}
			return
		}
		u = uint64(v)
		return
	case muint64:
		p, err = m.R.Next(9)
		if err != nil {
			return
		}
		u = getMuint64(p)
		return
	default:
		if isnfixint(lead) {
			err = UintBelowZero{Value: int64(rnfixint(lead))}
		} else {
			err = badPrefix(UintType, lead)
		}
		return
	}
}
func (m *Reader) ReadUint32() (u uint32, err error) {
	var in uint64
	in, err = m.ReadUint64()
	if in > math.MaxUint32 {
		err = UintOverflow{Value: in, FailedBitsize: 32}
		return
	}
	u = uint32(in)
	return
}
func (m *Reader) ReadUint16() (u uint16, err error) {
	var in uint64
	in, err = m.ReadUint64()
	if in > math.MaxUint16 {
		err = UintOverflow{Value: in, FailedBitsize: 16}
		return
	}
	u = uint16(in)
	return
}