pub struct Row { /* private fields */ }Expand description
A database row with hybrid access patterns.
Stores columns as ordered (Arc<str>, Value) pairs, preserving duplicates.
Column names are Arc<str> so that decoders can build them once per
statement and share them across every row of a result set (an Arc clone
instead of a fresh heap String per cell). Small rows use a linear scan
to avoid index-allocation overhead; wider rows lazily build a compact
name-to-index map on first get() call.
§Duplicate Column Policy
If multiple columns have the same name, get(name) returns the first occurrence.
Implementations§
Source§impl Row
impl Row
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create an empty row with enough capacity for the expected column count.
Sourcepub fn push_column(&mut self, name: impl Into<Arc<str>>, value: Value)
pub fn push_column(&mut self, name: impl Into<Arc<str>>, value: Value)
Append a column while constructing or reshaping a row.
Accepts anything convertible into Arc<str>: decoders pass shared
Arc<str> clones (no allocation), reshaping code can keep passing
Strings. This invalidates the lazy name index so subsequent lookups
stay correct.
Sourcepub fn get_by_pos(&self, idx: usize) -> Option<&Value>
pub fn get_by_pos(&self, idx: usize) -> Option<&Value>
Get a value by column position (0-indexed).
Sourcepub fn get(&self, name: &str) -> Option<&Value>
pub fn get(&self, name: &str) -> Option<&Value>
Get a value by column name.
Narrow rows use a direct scan. Wider rows lazily build an index on the first lookup. If duplicate columns exist, returns the first occurrence.
Sourcepub fn column_name(&self, idx: usize) -> Option<&str>
pub fn column_name(&self, idx: usize) -> Option<&str>
Get the column name at the given position.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>
Iterate over all columns as (name, value) pairs.
Trait Implementations§
Source§impl<'row> RowAccess<'row> for Row
Implement RowAccess trait for the owned Row type.
impl<'row> RowAccess<'row> for Row
Implement RowAccess trait for the owned Row type.
This allows Row to be used with the GAT-based executor interface while maintaining backward compatibility with existing code.
Auto Trait Implementations§
impl !Freeze for Row
impl RefUnwindSafe for Row
impl Send for Row
impl Sync for Row
impl Unpin for Row
impl UnsafeUnpin for Row
impl UnwindSafe for Row
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more