Expand description
Raw batch cursor API for zero-copy document processing.
This module provides a high-performance alternative to the standard cursor API when you need direct access to server response batches without per-document deserialization overhead.
§When to Use
Use RawBatchCursor when:
- Processing high-volume queries where deserialization is a bottleneck
- Implementing custom batch-level logic (e.g., batch transformation, filtering)
- Inspecting raw BSON structure without a known schema
- Forwarding documents without modification (e.g., proxying, caching)
Use regular Cursor when:
- Working with strongly-typed
Deserializedocuments - Iterating one document at a time
- Deserialization overhead is acceptable for your use case
§Example
use futures::stream::StreamExt;
let mut cursor = coll.find(doc! {}).batch().await?;
while let Some(batch) = cursor.next().await {
let batch = batch?;
// Zero-copy access to documents in this batch
for doc_result in batch.doc_slices()? {
let doc = doc_result?;
// Process raw document
}
}Structs§
- RawBatch
- A raw batch response returned by the server for a cursor getMore/find.
- RawBatch
Cursor - Streams the results of a query, providing direct access to each batch of results.
- Session
RawBatch Cursor - A raw batch cursor that was created with a
ClientSessionand must be iterated using one. - Session
RawBatch Cursor Stream - A
Streamtype for the results ofSessionRawBatchCursor. Returned fromSessionRawBatchCursor::stream.