Trait FromSqlRow

Source
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 structs using #[derive(FromSqlRow)].

§Example

#[derive(FromSqlRow)]
struct Person {
    age: i32,
    name: String,
    birthday: Option<Date<String>>,
}

Required Associated Constants§

Source

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§

Source

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Extract values from a single row.

Provided Methods§

Source

fn from_row_multi<R>(rows: &[R]) -> Result<Vec<Self>, Error>
where R: Row,

Extract values from multiple rows.

Implementors of this trait may override this method to enable optimizations not possible in from_row by, for example, only looking up the indices of columns with a specific name once.

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.

Implementations on Foreign Types§

Source§

impl<A> FromSqlRow for (A,)
where A: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 1usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B> FromSqlRow for (A, B)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 2usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C> FromSqlRow for (A, B, C)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 3usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C, D> FromSqlRow for (A, B, C, D)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display, D: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 4usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C, D, E> FromSqlRow for (A, B, C, D, E)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display, D: for<'a> FromSql<'a> + Display, E: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 5usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C, D, E, F> FromSqlRow for (A, B, C, D, E, F)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display, D: for<'a> FromSql<'a> + Display, E: for<'a> FromSql<'a> + Display, F: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 6usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C, D, E, F, G> FromSqlRow for (A, B, C, D, E, F, G)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display, D: for<'a> FromSql<'a> + Display, E: for<'a> FromSql<'a> + Display, F: for<'a> FromSql<'a> + Display, G: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 7usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<A, B, C, D, E, F, G, H> FromSqlRow for (A, B, C, D, E, F, G, H)
where A: for<'a> FromSql<'a> + Display, B: for<'a> FromSql<'a> + Display, C: for<'a> FromSql<'a> + Display, D: for<'a> FromSql<'a> + Display, E: for<'a> FromSql<'a> + Display, F: for<'a> FromSql<'a> + Display, G: for<'a> FromSql<'a> + Display, H: for<'a> FromSql<'a> + Display,

Source§

const COLUMN_COUNT: usize = 8usize

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<T> FromSqlRow for Option<T>
where T: FromSqlRow,

Source§

const COLUMN_COUNT: usize = T::COLUMN_COUNT

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<T> FromSqlRow for Box<T>
where T: FromSqlRow,

Source§

const COLUMN_COUNT: usize = T::COLUMN_COUNT

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<T> FromSqlRow for Rc<T>
where T: FromSqlRow,

Source§

const COLUMN_COUNT: usize = T::COLUMN_COUNT

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<T> FromSqlRow for Arc<T>
where T: FromSqlRow,

Source§

const COLUMN_COUNT: usize = T::COLUMN_COUNT

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Source§

impl<T, E> FromSqlRow for Result<T, E>
where T: FromSqlRow, E: From<Error>,

Source§

const COLUMN_COUNT: usize = T::COLUMN_COUNT

Source§

fn from_row<R>(row: &R) -> Result<Self, Error>
where R: Row,

Implementors§