Skip to main content

Row

Struct Row 

Source
pub struct Row { /* private fields */ }
Expand description

A single row returned from a database query.

Rows provide both index-based and name-based access to column values. Column metadata is shared via Arc for memory efficiency.

Implementations§

Source§

impl Row

Source

pub fn new(column_names: Vec<String>, values: Vec<Value>) -> Self

Create a new row with the given columns and values.

For multiple rows from the same result set, prefer with_columns to share the column metadata.

Source

pub fn subset_by_prefix(&self, prefix: &str) -> Self

Extract a subset of columns with a given prefix.

This is useful for eager loading where columns are aliased like table__column. This method extracts columns matching prefix__* and returns a new Row with the prefix stripped.

§Example
let row = Row::new(
    vec!["heroes__id", "heroes__name", "teams__id", "teams__name"],
    vec![Value::Int(1), Value::Text("Hero".into()), Value::Int(10), Value::Text("Team".into())],
);
let hero_row = row.subset_by_prefix("heroes");
// hero_row has columns: ["id", "name"] with values [1, "Hero"]
Source

pub fn has_prefix(&self, prefix: &str) -> bool

Check if this row has any columns with the given prefix.

Useful for checking if a LEFT JOIN returned NULL (no matching rows).

Source

pub fn prefix_is_all_null(&self, prefix: &str) -> bool

Check if all values with a given prefix are NULL.

Used to detect LEFT JOIN rows where no related record exists.

Source

pub fn with_columns(columns: Arc<ColumnInfo>, values: Vec<Value>) -> Self

Create a new row with shared column metadata.

This is more efficient for creating multiple rows from the same query.

Source

pub fn column_info(&self) -> Arc<ColumnInfo>

Get the shared column metadata.

Use this to create additional rows that share the same column info.

Source

pub fn len(&self) -> usize

Get the number of columns in this row.

Source

pub fn is_empty(&self) -> bool

Check if this row is empty.

Source

pub fn get(&self, index: usize) -> Option<&Value>

Get a value by column index. O(1) operation.

Source

pub fn get_by_name(&self, name: &str) -> Option<&Value>

Get a value by column name. O(1) operation via HashMap lookup.

Source

pub fn contains_column(&self, name: &str) -> bool

Check if a column exists by name.

Source

pub fn get_as<T: FromValue>(&self, index: usize) -> Result<T>

Get a typed value by column index.

Source

pub fn get_named<T: FromValue>(&self, name: &str) -> Result<T>

Get a typed value by column name.

Source

pub fn column_names(&self) -> impl Iterator<Item = &str>

Get all column names.

Source

pub fn values(&self) -> impl Iterator<Item = &Value>

Iterate over all values.

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &Value)>

Iterate over (column_name, value) pairs.

Trait Implementations§

Source§

impl Clone for Row

Source§

fn clone(&self) -> Row

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
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 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> 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> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> 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<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