Skip to main content

Row

Struct Row 

Source
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

Source

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.

Source

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.

Source

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);
Source

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
Source

pub fn get_i16(&self, idx: usize) -> Option<i16>

Gets an i16 value at the given column index.

Source

pub fn get_i32(&self, idx: usize) -> Option<i32>

Gets an i32 value at the given column index.

Source

pub fn get_i64(&self, idx: usize) -> Option<i64>

Gets an i64 value at the given column index.

Source

pub fn get_f32(&self, idx: usize) -> Option<f32>

Gets an f32 value at the given column index.

Source

pub fn get_f64(&self, idx: usize) -> Option<f64>

Gets an f64 value at the given column index.

Source

pub fn get_bool(&self, idx: usize) -> Option<bool>

Gets a bool value at the given column index.

Source

pub fn get_string(&self, idx: usize) -> Option<String>

Gets a String value at the given column index.

Source

pub fn is_null(&self, idx: usize) -> bool

Checks if the value at the given column is null.

Source

pub fn column_count(&self) -> usize

Returns the number of columns in this row.

Source

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.

Source

pub fn get_date(&self, idx: usize) -> Option<Date>

Gets a Date value at the given column index.

Source

pub fn get_time(&self, idx: usize) -> Option<Time>

Gets a Time value at the given column index.

Source

pub fn get_timestamp(&self, idx: usize) -> Option<Timestamp>

Gets a Timestamp value at the given column index.

Source

pub fn get_offset_timestamp(&self, idx: usize) -> Option<OffsetTimestamp>

Gets an OffsetTimestamp (TIMESTAMP WITH TIME ZONE) value at the given column index.

Source

pub fn get_interval(&self, idx: usize) -> Option<Interval>

Gets an Interval value at the given column index.

Source

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 like AVG(INTEGER) return as Numeric(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§

Source§

impl Debug for Row

Source§

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

Formats the value using the given formatter. Read more

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> 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more