pub struct Row { /* private fields */ }Expand description
A row from a query result, providing typed value access.
This type abstracts over the underlying transport (TCP or gRPC), providing a consistent API for accessing column values regardless of how the data was retrieved.
§Example
for row in result.rows() {
let row = row?;
let id: Option<i32> = row.get(0);
let name: Option<String> = row.get(1);
// Or use direct accessors
let value = row.get_f64(2);
}Implementations§
Source§impl Row
impl Row
Sourcepub fn schema(&self) -> Option<&ResultSchema>
pub fn schema(&self) -> Option<&ResultSchema>
Returns the schema this row belongs to, if attached.
Every row produced by Rowset::next_chunk has a schema
attached — so this returns Some for any row obtained through
the public API.
Sourcepub fn sql_type(&self, idx: usize) -> Option<SqlType>
pub fn sql_type(&self, idx: usize) -> Option<SqlType>
Returns the SqlType of the column at the given index, if the
schema is attached and the index is in bounds.
Useful for metadata-dependent decoders like Self::get_numeric
that need per-column precision and scale. Most callers reach for
Self::get / Self::try_get instead, which handle this
lookup internally via the RowValue trait.
Sourcepub fn get<T: RowValue>(&self, idx: usize) -> Option<T>
pub fn get<T: RowValue>(&self, idx: usize) -> Option<T>
Gets a typed value at the given column index.
§Example
let id: Option<i32> = row.get(0);
let name: Option<String> = row.get(1);Sourcepub fn try_get<T: RowValue>(&self, idx: usize, column_name: &str) -> Result<T>
pub fn try_get<T: RowValue>(&self, idx: usize, column_name: &str) -> Result<T>
Gets a typed value at the given column index, returning a Result
with a descriptive error on failure.
Use this in FromRow implementations for better error messages
than bare row.get(idx).ok_or(...).
§Example
impl FromRow for User {
fn from_row(row: &Row) -> Result<Self> {
Ok(User {
id: row.try_get::<i32>(0, "id")?,
name: row.try_get::<String>(1, "name")?,
})
}
}§Errors
- Returns
crate::Error::Otherifidxis out of bounds for the row’s column count. - Returns
crate::Error::Otherif the cell is SQLNULLor its value cannot be decoded asT.
Sourcepub fn get_bool(&self, idx: usize) -> Option<bool>
pub fn get_bool(&self, idx: usize) -> Option<bool>
Gets a bool value at the given column index.
Sourcepub fn get_string(&self, idx: usize) -> Option<String>
pub fn get_string(&self, idx: usize) -> Option<String>
Gets a String value at the given column index.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns in this row.
Sourcepub fn get_bytes(&self, idx: usize) -> Option<Vec<u8>>
pub fn get_bytes(&self, idx: usize) -> Option<Vec<u8>>
Gets raw bytes at the given column index.
For TCP rows, returns the raw binary data. For Arrow rows, this method is not available and returns None.
Sourcepub fn get_date(&self, idx: usize) -> Option<Date>
pub fn get_date(&self, idx: usize) -> Option<Date>
Gets a Date value at the given column index.
Sourcepub fn get_time(&self, idx: usize) -> Option<Time>
pub fn get_time(&self, idx: usize) -> Option<Time>
Gets a Time value at the given column index.
Sourcepub fn get_timestamp(&self, idx: usize) -> Option<Timestamp>
pub fn get_timestamp(&self, idx: usize) -> Option<Timestamp>
Gets a Timestamp value at the given column index.
Sourcepub fn get_offset_timestamp(&self, idx: usize) -> Option<OffsetTimestamp>
pub fn get_offset_timestamp(&self, idx: usize) -> Option<OffsetTimestamp>
Gets an OffsetTimestamp (TIMESTAMP WITH TIME ZONE) value at the given column index.
Sourcepub fn get_interval(&self, idx: usize) -> Option<Interval>
pub fn get_interval(&self, idx: usize) -> Option<Interval>
Gets an Interval value at the given column index.
Sourcepub fn get_numeric(&self, idx: usize) -> Option<Numeric>
pub fn get_numeric(&self, idx: usize) -> Option<Numeric>
Gets a NUMERIC value at the given column index.
This is the metadata-aware variant of Self::get_bytes +
hyperdb_api_core::types::Numeric::from_binary_with_scale: it looks up
the column’s SqlType::Numeric { scale, .. } from the attached
schema and decodes the wire bytes with that scale, handling
both of Hyper’s NUMERIC wire forms transparently:
- 8 bytes (i64) when the column’s declared precision ≤ 18
(Hyper’s
Type::Numeric). This is what aggregates likeAVG(INTEGER)return asNumeric(16, 6). - 16 bytes (i128) when declared precision > 18
(Hyper’s
Type::BigNumeric).
Returns None if any of the following are true: the value is
NULL, the schema isn’t attached (which never happens for rows
obtained through Rowset::next_chunk), the column at idx
isn’t NUMERIC, or the bytes can’t be decoded.
For non-TCP (Arrow/gRPC) rows, this path falls back to reading
the Arrow-native Decimal128 / Decimal256 columns; the scale
lives in the Arrow type descriptor in that case.
Trait Implementations§
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> 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