pub struct DataRowBody { /* private fields */ }Expand description
Data row body.
Contains a single row of data from a query result. Each column is prefixed with a 4-byte length (BigEndian):
- Positive length: non-NULL value of that length
- -1: NULL value
Implementations§
Source§impl DataRowBody
impl DataRowBody
Sourcepub fn ranges(&self) -> DataRowRanges<'_> ⓘ
pub fn ranges(&self) -> DataRowRanges<'_> ⓘ
Returns an iterator over the column ranges.
Sourcepub fn column_count(&self) -> u16
pub fn column_count(&self) -> u16
Returns the number of columns.
Sourcepub fn compute_all_offsets(&self) -> Vec<Option<(usize, usize)>>
pub fn compute_all_offsets(&self) -> Vec<Option<(usize, usize)>>
Pre-computes offsets for all columns regardless of count.
Computes offsets for all columns in this row.
This provides O(1) access for any column index using dynamic allocation. Each entry is:
Some((start, end))for non-NULL values (byte range within the buffer)Nonefor NULL values or when parsing fails due to truncated data
§Performance Tradeoffs
This method allocates a Vec for all columns upfront. For tables with many
columns where only a few are accessed, this may use more memory than needed.
When to use this method:
- Accessing multiple columns from the same row
- Random access patterns where column indices vary
- Bulk processing where setup cost is amortized
Alternative for sparse access:
If you only need one or two columns from a wide table, consider using
get_raw(index) which computes offset on-demand (O(n) per call, but no
allocation).
§Memory Usage
Allocates column_count * size_of::<Option<(usize, usize)>>() bytes.
For a table with 100 columns, this is approximately 2.4 KB per row.
§Panics
Does not panic in practice. The usize::try_from(len) call is
guarded by a len >= 0 check, so the conversion from i32 to
usize is always infallible.
Sourcepub fn get_column_bytes(&self, idx: usize) -> Option<&[u8]>
pub fn get_column_bytes(&self, idx: usize) -> Option<&[u8]>
Gets raw bytes for a column by index, computing offset on demand. Returns None if NULL or out of bounds. This avoids allocating a Vec of ranges.
§Panics
Does not panic in practice. The usize::try_from(len) calls are
guarded by a len >= 0 check in each branch, making the
i32 -> usize conversion infallible.
Sourcepub fn is_column_null(&self, idx: usize) -> bool
pub fn is_column_null(&self, idx: usize) -> bool
Checks if a column is NULL.
§Panics
Does not panic in practice. Each usize::try_from(len) is guarded
by a len >= 0 check, so the conversion from i32 cannot fail.
Trait Implementations§
Source§impl Clone for DataRowBody
impl Clone for DataRowBody
Source§fn clone(&self) -> DataRowBody
fn clone(&self) -> DataRowBody
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for DataRowBody
impl RefUnwindSafe for DataRowBody
impl Send for DataRowBody
impl Sync for DataRowBody
impl Unpin for DataRowBody
impl UnsafeUnpin for DataRowBody
impl UnwindSafe for DataRowBody
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request