Skip to main content

RowRef

Trait RowRef 

Source
pub trait RowRef {
Show 31 methods // Required methods fn get_i32(&self, column: &str) -> Result<i32, RowError>; fn get_i32_opt(&self, column: &str) -> Result<Option<i32>, RowError>; fn get_i64(&self, column: &str) -> Result<i64, RowError>; fn get_i64_opt(&self, column: &str) -> Result<Option<i64>, RowError>; fn get_f64(&self, column: &str) -> Result<f64, RowError>; fn get_f64_opt(&self, column: &str) -> Result<Option<f64>, RowError>; fn get_bool(&self, column: &str) -> Result<bool, RowError>; fn get_bool_opt(&self, column: &str) -> Result<Option<bool>, RowError>; fn get_str(&self, column: &str) -> Result<&str, RowError>; fn get_str_opt(&self, column: &str) -> Result<Option<&str>, RowError>; fn get_bytes(&self, column: &str) -> Result<&[u8], RowError>; fn get_bytes_opt(&self, column: &str) -> Result<Option<&[u8]>, RowError>; // Provided methods fn get_string(&self, column: &str) -> Result<String, RowError> { ... } fn get_string_opt(&self, column: &str) -> Result<Option<String>, RowError> { ... } fn get_cow_str(&self, column: &str) -> Result<Cow<'_, str>, RowError> { ... } fn get_datetime_utc(&self, column: &str) -> Result<DateTime<Utc>, RowError> { ... } fn get_datetime_utc_opt( &self, column: &str, ) -> Result<Option<DateTime<Utc>>, RowError> { ... } fn get_naive_datetime( &self, column: &str, ) -> Result<NaiveDateTime, RowError> { ... } fn get_naive_datetime_opt( &self, column: &str, ) -> Result<Option<NaiveDateTime>, RowError> { ... } fn get_naive_date(&self, column: &str) -> Result<NaiveDate, RowError> { ... } fn get_naive_date_opt( &self, column: &str, ) -> Result<Option<NaiveDate>, RowError> { ... } fn get_naive_time(&self, column: &str) -> Result<NaiveTime, RowError> { ... } fn get_naive_time_opt( &self, column: &str, ) -> Result<Option<NaiveTime>, RowError> { ... } fn get_uuid(&self, column: &str) -> Result<Uuid, RowError> { ... } fn get_uuid_opt(&self, column: &str) -> Result<Option<Uuid>, RowError> { ... } fn get_json(&self, column: &str) -> Result<Value, RowError> { ... } fn get_json_opt(&self, column: &str) -> Result<Option<Value>, RowError> { ... } fn get_decimal(&self, column: &str) -> Result<Decimal, RowError> { ... } fn get_decimal_opt(&self, column: &str) -> Result<Option<Decimal>, RowError> { ... } fn get_vector(&self, column: &str) -> Result<Vec<f32>, RowError> { ... } fn is_null(&self, column: &str) -> Result<bool, RowError> { ... }
}
Expand description

A database row that supports zero-copy access.

This trait is implemented by database-specific row types to enable efficient data extraction without unnecessary copying.

Required Methods§

Source

fn get_i32(&self, column: &str) -> Result<i32, RowError>

Get an integer column value.

Source

fn get_i32_opt(&self, column: &str) -> Result<Option<i32>, RowError>

Get an optional integer column value.

Source

fn get_i64(&self, column: &str) -> Result<i64, RowError>

Get a 64-bit integer column value.

Source

fn get_i64_opt(&self, column: &str) -> Result<Option<i64>, RowError>

Get an optional 64-bit integer column value.

Source

fn get_f64(&self, column: &str) -> Result<f64, RowError>

Get a float column value.

Source

fn get_f64_opt(&self, column: &str) -> Result<Option<f64>, RowError>

Get an optional float column value.

Source

fn get_bool(&self, column: &str) -> Result<bool, RowError>

Get a boolean column value.

Source

fn get_bool_opt(&self, column: &str) -> Result<Option<bool>, RowError>

Get an optional boolean column value.

Source

fn get_str(&self, column: &str) -> Result<&str, RowError>

Get a string column value as a borrowed reference (zero-copy).

This is the key method for zero-copy deserialization. The returned string slice borrows directly from the row’s internal buffer.

Source

fn get_str_opt(&self, column: &str) -> Result<Option<&str>, RowError>

Get an optional string column value as a borrowed reference.

Source

fn get_bytes(&self, column: &str) -> Result<&[u8], RowError>

Get a bytes column value as a borrowed reference (zero-copy).

Source

fn get_bytes_opt(&self, column: &str) -> Result<Option<&[u8]>, RowError>

Get optional bytes as borrowed reference.

Provided Methods§

Source

fn get_string(&self, column: &str) -> Result<String, RowError>

Get a string column value as owned (for cases where ownership is needed).

Source

fn get_string_opt(&self, column: &str) -> Result<Option<String>, RowError>

Get an optional string as owned.

Source

fn get_cow_str(&self, column: &str) -> Result<Cow<'_, str>, RowError>

Get column value as a Cow, borrowing when possible.

Source

fn get_datetime_utc(&self, column: &str) -> Result<DateTime<Utc>, RowError>

Source

fn get_datetime_utc_opt( &self, column: &str, ) -> Result<Option<DateTime<Utc>>, RowError>

Source

fn get_naive_datetime(&self, column: &str) -> Result<NaiveDateTime, RowError>

Source

fn get_naive_datetime_opt( &self, column: &str, ) -> Result<Option<NaiveDateTime>, RowError>

Source

fn get_naive_date(&self, column: &str) -> Result<NaiveDate, RowError>

Source

fn get_naive_date_opt( &self, column: &str, ) -> Result<Option<NaiveDate>, RowError>

Source

fn get_naive_time(&self, column: &str) -> Result<NaiveTime, RowError>

Source

fn get_naive_time_opt( &self, column: &str, ) -> Result<Option<NaiveTime>, RowError>

Source

fn get_uuid(&self, column: &str) -> Result<Uuid, RowError>

Source

fn get_uuid_opt(&self, column: &str) -> Result<Option<Uuid>, RowError>

Source

fn get_json(&self, column: &str) -> Result<Value, RowError>

Source

fn get_json_opt(&self, column: &str) -> Result<Option<Value>, RowError>

Source

fn get_decimal(&self, column: &str) -> Result<Decimal, RowError>

Source

fn get_decimal_opt(&self, column: &str) -> Result<Option<Decimal>, RowError>

Source

fn get_vector(&self, column: &str) -> Result<Vec<f32>, RowError>

Get a pgvector column as a dense Vec<f32>.

Default impl errors with unsupported_get; prax-postgres overrides this on its RowRef impl to decode the on-wire pgvector representation. Used by the blanket FromColumn for Vec<f32> impl below so schema-generated structs with a Vector(N) field compile out of the box.

Source

fn is_null(&self, column: &str) -> Result<bool, RowError>

Check whether the named column is NULL in this row.

The default implementation delegates to get_str_opt — every driver backend already implements that one. Drivers with a faster null probe (e.g. postgres’s row.try_get::<_, Option<&str>> avoids a full string allocation) can override this method.

Used by the blanket impl<T: FromColumn> FromColumn for Option<T> to dispatch between a nullable decode and the inner type’s non-null decode, so user-defined enums and other custom types can round-trip through a nullable column without needing a bespoke FromColumn for Option<MyEnum> (which the orphan rule would forbid the consumer crate from writing).

Implementors§