You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: document_sequence.go
    path of file: ./repos/ko/vendor/go.mongodb.org/mongo-driver/x/bsonx/bsoncore
    
    the code of the file until where you have to start completion: // Copyright (C) MongoDB, Inc. 2022-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package bsoncore

import (
	
    
func (ds *DocumentSequence) Next() (Document, error) {
	if ds == nil || ds.Pos >= len(ds.Data) {
		return nil, io.EOF
	}
	switch ds.Style {
	case SequenceStyle:
		doc, _, ok := ReadDocument(ds.Data[ds.Pos:])
		if !ok {
			return nil, ErrCorruptedDocument
		}
		ds.Pos += len(doc)
		return doc, nil
	case ArrayStyle:
		if ds.Pos < 4 {
			if len(ds.Data) < 4 {
				return nil, ErrCorruptedDocument
			}
			ds.Pos = 4 // Skip the length of the document
		}
		if len(ds.Data[ds.Pos:]) == 1 && ds.Data[ds.Pos] == 0x00 {
			return nil, io.EOF // At the end of the document
		}
		elem, _, ok := ReadElement(ds.Data[ds.Pos:])
		if !ok {
			return nil, ErrCorruptedDocument
		}
		ds.Pos += len(elem)
		val := elem.Value()
		if val.Type != bsontype.EmbeddedDocument {
			return nil, ErrNonDocument
		}
		return val.Data, nil
	default:
		return nil, ErrInvalidDocumentSequenceStyle
	}
}