func NewBSONDocumentReader(b []byte) ValueReader {
	return newValueReader(b)
}
NewBSONDocumentReader returns a ValueReader using b for the underlying BSON
representation. Parameter b must be a BSON Document.

TODO(skriptble): There's a lack of symmetry between the reader and writer, since the reader takes
a []byte while the writer takes an io.Writer. We should have two versions of each, one that takes
a []byte and one that takes an io.Reader or io.Writer. The []byte version will need to return a
thing that can return the finished []byte since it might be reallocated when appended to.
package bsonrw
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"math"
	"sync"
	"go.mongodb.org/mongo-driver/bson/bsontype"
	"go.mongodb.org/mongo-driver/bson/primitive"
)
var _ ValueReader = (*valueReader)(nil)
var vrPool = sync.Pool{
	New: func() interface{} {
		return new(valueReader)
	},
}
type BSONValueReaderPool struct {
	pool sync.Pool
}
func NewBSONValueReaderPool() *BSONValueReaderPool {
	return &BSONValueReaderPool{
		pool: sync.Pool{
			New: func() interface{} {
				return new(valueReader)
			},
		},
	}
}
func (bvrp *BSONValueReaderPool) Get(src []byte) ValueReader {
	vr := bvrp.pool.Get().(*valueReader)
	vr.reset(src)
	return vr
}
func (bvrp *BSONValueReaderPool) Put(vr ValueReader) (ok bool) {
	bvr, ok := vr.(*valueReader)
	if !ok {
		return false
	}
	bvr.reset(nil)
	bvrp.pool.Put(bvr)
	return true
}
var ErrEOA = errors.New("end of array")
var ErrEOD = errors.New("end of document")
type vrState struct {
	mode  mode
	vType bsontype.Type
	end   int64
}
type valueReader struct {
	offset int64
	d      []byte
	stack []vrState
	frame int64
}