Skip to main content

Row

Struct Row 

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

A row returned from a query. Contains column descriptions and raw data.

Column descriptors are shared via Rc across all rows in a result set, avoiding expensive deep clones on every DataRow message.

Column values use [CompactBytes] — values ≤ 24 bytes are stored inline (no heap allocation), which covers all binary-format scalar types.

Implementations§

Source§

impl Row

Source

pub fn new(columns: Rc<Vec<ColumnDesc>>, raw_values: Vec<Option<&[u8]>>) -> Row

Create a new row from shared column descriptions and raw column data.

Small values (≤ 24 bytes) are stored inline with zero heap allocation.

Source

pub fn mock(names: &[&str], values: &[PgValue]) -> Row

Safely create a mock row for testing, bypassing wire protocols.

Source

pub fn len(&self) -> usize

Get the number of columns.

Source

pub fn is_empty(&self) -> bool

Check if the row is empty.

Source

pub fn get(&self, index: usize) -> Result<PgValue, PgError>

Get a column value by index as a PgValue.

Source

pub fn get_by_name(&self, name: &str) -> Result<PgValue, PgError>

Get a column value by name as a PgValue.

Source

pub fn get_typed<T>(&self, index: usize) -> Result<T, PgError>
where T: FromSql,

Get a typed value by column index using the FromSql trait.

§Example
let name: String = row.get_typed(0)?;
let age: Option<i32> = row.get_typed(1)?;
Source

pub fn get_typed_by_name<T>(&self, name: &str) -> Result<T, PgError>
where T: FromSql,

Get a typed value by column name using the FromSql trait.

Source

pub fn get_str(&self, index: usize) -> Result<Option<&str>, PgError>

Get a column as a string (text representation).

Source

pub fn get_i32(&self, index: usize) -> Result<Option<i32>, PgError>

Get a column as i32.

Source

pub fn get_i64(&self, index: usize) -> Result<Option<i64>, PgError>

Get a column as i64.

Source

pub fn get_bool(&self, index: usize) -> Result<Option<bool>, PgError>

Get a column as bool.

Source

pub fn get_f64(&self, index: usize) -> Result<Option<f64>, PgError>

Get a column as f64.

Source

pub fn get_uuid(&self, index: usize) -> Result<Option<[u8; 16]>, PgError>

Get a column as a UUID string (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Source

pub fn columns(&self) -> &[ColumnDesc]

Get column descriptions.

Source

pub fn column_name(&self, index: usize) -> Option<&str>

Get a column name by index.

Source

pub fn column_index(&self, name: &str) -> Option<usize>

Find a column index by name.

Trait Implementations§

Source§

impl Debug for Row

Source§

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

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, 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, 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.