Trait postgres_mapper::FromPostgresRow [−][src]
pub trait FromPostgresRow: Sized { fn from_postgres_row(row: PostgresRow) -> Result<Self, Error>; fn from_postgres_row_ref(row: &PostgresRow) -> Result<Self, Error>; }
Trait containing various methods for converting from a postgres Row to a mapped type.
When using the postgres_mapper_derive
crate's PostgresMapper
proc-macro,
this will automatically be implemented on types.
The [from_postgres_row
] method exists for consuming a Row
- useful for
iterator mapping - while [from_postgres_row_ref
] exists for borrowing a
Row
.
Required Methods
fn from_postgres_row(row: PostgresRow) -> Result<Self, Error>
Converts from a postgres Row
into a mapped type, consuming the given
Row
.
Errors
Returns Error::ColumnNotFound
if the column in a mapping was not
found.
Returns Error::Postgres
if there was an error converting the row
column to the requested type.
fn from_postgres_row_ref(row: &PostgresRow) -> Result<Self, Error>
Converts from a postgres
Row
into a mapped type, borrowing the given
Row
.
Errors
Returns Error::ColumnNotFound
if the column in a mapping was not
found.
Returns Error::Postgres
if there was an error converting the row
column to the requested type.