pub struct BorrowedRowBatch { /* private fields */ }Expand description
A decoded fetch batch that owns the wire response buffer and column
metadata, and yields rows of borrowed QueryValueRef that point straight
into that buffer. This is the zero-copy fetch fast path: the common scalar
grid is decoded with no per-cell allocation.
§Soundness
The buffer is owned by the batch and outlives every borrowed row: rows are
only ever surfaced inside the for_each_row_ref
callback, whose &[QueryValueRef] argument cannot escape (its lifetime is
bound to the call). The borrow checker therefore guarantees no
QueryValueRef can dangle — there is no self-referential struct and no
unsafe. Number text and the cold values borrow per-row arenas that are
fully built (pass 1) before any reference into them is taken (pass 2), so an
arena is never grown while borrowed.
Implementations§
Source§impl BorrowedRowBatch
impl BorrowedRowBatch
Sourcepub fn new(
buffer: Vec<u8>,
columns: Vec<ColumnMetadata>,
row_starts: Vec<usize>,
) -> Self
pub fn new( buffer: Vec<u8>, columns: Vec<ColumnMetadata>, row_starts: Vec<usize>, ) -> Self
Construct a batch from an owned wire buffer, the columns describing
each cell, and the per-row start offsets into buffer. Use this for
batches with no duplicate-column compression and no LONG trailers (the
common synthetic / test case); the framing-aware
parse_query_response_borrowed builds the full form.
Sourcepub fn columns(&self) -> &[ColumnMetadata]
pub fn columns(&self) -> &[ColumnMetadata]
The columns describing each cell.
Sourcepub fn for_each_row_ref<F, E>(&self, callback: F) -> Result<(), E>
pub fn for_each_row_ref<F, E>(&self, callback: F) -> Result<(), E>
Decode each row and invoke callback with the row’s borrowed cells. The
&[Option<QueryValueRef>] slice borrows the batch buffer and per-row
arenas; it is valid only for the duration of the call (it cannot escape).
None cells are SQL NULL. Returns the first decode/callback error.
Generic over the callback’s error type E (any error a decode failure
can convert into, e.g. the driver crate’s own error) so callers are not
forced through ProtocolError; a decode failure is surfaced via
E: From<ProtocolError>.
Trait Implementations§
Source§impl Clone for BorrowedRowBatch
impl Clone for BorrowedRowBatch
Source§fn clone(&self) -> BorrowedRowBatch
fn clone(&self) -> BorrowedRowBatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more