pub trait FromSqlRow<A, DB: Backend>: Sized {
const FIELDS_NEEDED: usize = 1usize;
// Required method
fn build_from_row<T: Row<DB>>(row: &mut T) -> Result<Self>;
}
Expand description
Deserialize one or more fields.
All types which implement FromSql
should also implement this trait. This
trait differs from FromSql
in that it is also implemented by tuples.
Implementations of this trait are usually derived.
In the future, we hope to be able to provide a blanket impl of this trait
for all types which implement FromSql
. However, as of Diesel 1.0, such an
impl would conflict with our impl for tuples.
§Deriving
This trait can be automatically derived by Diesel
for any type which implements FromSql
.
There are no options or special considerations needed for this derive.
Note that #[derive(FromSqlRow)]
will also generate a Queryable
implementation.
Provided Associated Constants§
Sourceconst FIELDS_NEEDED: usize = 1usize
const FIELDS_NEEDED: usize = 1usize
The number of fields that this type will consume. Must be equal to
the number of times you would call row.take()
in build_from_row
Required Methods§
Sourcefn build_from_row<T: Row<DB>>(row: &mut T) -> Result<Self>
fn build_from_row<T: Row<DB>>(row: &mut T) -> Result<Self>
See the trait documentation.
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.