pub trait FromSqlRow: Sized {
const COLUMN_COUNT: usize;
// Required method
fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row;
// Provided method
fn from_row_multi<R>(rows: &[R]) -> Result<Vec<Self>, Error>
where R: Row { ... }
}
Expand description
Extract values from a row.
May be derived for struct
s using #[derive(FromSqlRow)]
.
§Example
#[derive(FromSqlRow)]
struct Person {
age: i32,
name: String,
birthday: Option<Date<String>>,
}
Required Associated Constants§
Sourceconst COLUMN_COUNT: usize
const COLUMN_COUNT: usize
Number of columns required to construct this type.
IMPORTANT: if not set correctly, extractors which depend on this value may produce errors.
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.