Skip to main content

BorrowedRowBatch

Struct BorrowedRowBatch 

Source
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

Source

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.

Source

pub fn row_count(&self) -> usize

Number of rows in the batch.

Source

pub fn columns(&self) -> &[ColumnMetadata]

The columns describing each cell.

Source

pub fn for_each_row_ref<F, E>(&self, callback: F) -> Result<(), E>
where F: FnMut(&[Option<QueryValueRef<'_>>]) -> Result<(), E>, E: From<ProtocolError>,

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

Source§

fn clone(&self) -> BorrowedRowBatch

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BorrowedRowBatch

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V