pub struct TypedRow<'a> { /* private fields */ }Expand description
A borrowed view of one row of a QueryResult that converts cells to typed
Rust values. Obtain it with QueryResultExt::typed_row.
Implementations§
Source§impl TypedRow<'_>
impl TypedRow<'_>
Sourcepub fn get<T: FromSql>(&self, col: usize) -> Result<T>
pub fn get<T: FromSql>(&self, col: usize) -> Result<T>
Convert the cell in this row at column index col into T.
Sourcepub fn get_by_name<T: FromSql>(&self, name: &str) -> Result<T>
pub fn get_by_name<T: FromSql>(&self, name: &str) -> Result<T>
Convert the cell in this row at column name (case-insensitive) into
T.
Sourcepub fn try_get<T: FromSql>(&self, col: usize) -> Result<T, ConversionError>
pub fn try_get<T: FromSql>(&self, col: usize) -> Result<T, ConversionError>
Convert the cell in this row at column index col into T, yielding the
bare ConversionError on failure (unlike TypedRow::get, which
wraps it in crate::Error). A SQL NULL cell is rejected with
ConversionError::UnexpectedNull; use TypedRow::try_get_opt for a
nullable column.
This is the accessor the #[derive(FromRow)]-generated code uses for
non-Option tuple-struct fields. It is pub so generated code can call
it; hand-written code usually wants TypedRow::get.
Sourcepub fn try_get_opt<T: FromSql>(
&self,
col: usize,
) -> Result<Option<T>, ConversionError>
pub fn try_get_opt<T: FromSql>( &self, col: usize, ) -> Result<Option<T>, ConversionError>
Like TypedRow::try_get but for an Option<T> field: a SQL NULL
cell becomes None. The accessor #[derive(FromRow)] uses for
Option<T> tuple-struct fields.
Sourcepub fn try_get_by_name<T: FromSql>(
&self,
name: &str,
) -> Result<T, ConversionError>
pub fn try_get_by_name<T: FromSql>( &self, name: &str, ) -> Result<T, ConversionError>
Convert the cell in this row at column name (case-insensitive) into
T, yielding the bare ConversionError on failure (unlike
TypedRow::get_by_name, which wraps it in crate::Error). A SQL
NULL cell is rejected with ConversionError::UnexpectedNull; use
TypedRow::try_get_by_name_opt for a nullable column.
This is the accessor the #[derive(FromRow)]-generated code uses for
non-Option named-field structs. It is pub so generated code can call
it; hand-written code usually wants TypedRow::get_by_name.
Sourcepub fn try_get_by_name_opt<T: FromSql>(
&self,
name: &str,
) -> Result<Option<T>, ConversionError>
pub fn try_get_by_name_opt<T: FromSql>( &self, name: &str, ) -> Result<Option<T>, ConversionError>
Like TypedRow::try_get_by_name but for an Option<T> field: a SQL
NULL cell becomes None. The accessor #[derive(FromRow)] uses for
Option<T> named-field structs.