func (c *Cursor) Decode(val interface{}) error {
	return bson.UnmarshalWithRegistry(c.registry, c.Current, val)
}
Decode will unmarshal the current document into val and return any errors from the unmarshalling process without any
modification. If val is nil or is a typed nil, an error will be returned.
package mongo
import (
	"context"
	"errors"
	"fmt"
	"io"
	"reflect"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/bson/bsoncodec"
	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
	"go.mongodb.org/mongo-driver/x/mongo/driver"
	"go.mongodb.org/mongo-driver/x/mongo/driver/session"
)
type Cursor struct {
	Current bson.Raw
	bc            batchCursor
	batch         *bsoncore.DocumentSequence
	batchLength   int
	registry      *bsoncodec.Registry
	clientSession *session.Client
	err error
}
func newCursor(bc batchCursor, registry *bsoncodec.Registry) (*Cursor, error) {
	return newCursorWithSession(bc, registry, nil)
}
func newCursorWithSession(bc batchCursor, registry *bsoncodec.Registry, clientSession *session.Client) (*Cursor, error) {
	if registry == nil {
		registry = bson.DefaultRegistry
	}
	if bc == nil {
		return nil, errors.New("batch cursor must not be nil")
	}
	c := &Cursor{
		bc:            bc,
		registry:      registry,
		clientSession: clientSession,
	}
	if bc.ID() == 0 {
		c.closeImplicitSession()
	}
	c.batchLength = c.bc.Batch().DocumentCount()
	return c, nil
}
func newEmptyCursor() *Cursor {
	return &Cursor{bc: driver.NewEmptyBatchCursor()}
}
func (c *Cursor) ID() int64 { return c.bc.ID() }
func (c *Cursor) Next(ctx context.Context) bool {
	return c.next(ctx, false)
}
func (c *Cursor) TryNext(ctx context.Context) bool {
	return c.next(ctx, true)
}
func (c *Cursor) next(ctx context.Context, nonBlocking bool) bool {
	if c.err != nil {
		return false
	}
	if ctx == nil {
		ctx = context.Background()
	}
	doc, err := c.batch.Next()
	switch err {
	case nil:
		c.batchLength--
		c.Current = bson.Raw(doc)
		return true
	case io.EOF:  
	default:
		c.err = err
		return false
	}
	for {
		if !c.bc.Next(ctx) {
			c.err = replaceErrors(c.bc.Err())
			if c.err != nil {
				return false
			}
			if c.bc.ID() == 0 {
				c.closeImplicitSession()
				return false
			}
			if nonBlocking {
				return false
			}
			continue
		}
		if c.bc.ID() == 0 {
			c.closeImplicitSession()
		}
		c.batch = c.bc.Batch()
		c.batchLength = c.batch.DocumentCount()
		doc, err = c.batch.Next()
		switch err {
		case nil:
			c.batchLength--
			c.Current = bson.Raw(doc)
			return true
		case io.EOF:  
		default:
			c.err = err
			return false
		}
	}
}