diesel::row

Trait Row

Source
pub trait Row<'a, DB: Backend>:
    RowIndex<usize>
    + for<'b> RowIndex<&'b str>
    + RowSealed
    + Sized {
    type Field<'f>: Field<'f, DB>
       where Self: 'f,
             'a: 'f;
    type InnerPartialRow: Row<'a, DB>;

    // Required methods
    fn field_count(&self) -> usize;
    fn get<'b, I>(&'b self, idx: I) -> Option<Self::Field<'b>>
       where Self: RowIndex<I>,
             'a: 'b;
    fn partial_row(
        &self,
        range: Range<usize>,
    ) -> PartialRow<'_, Self::InnerPartialRow>;

    // Provided method
    fn get_value<ST, T, I>(&self, idx: I) -> Result<T>
       where Self: RowIndex<I>,
             T: FromSql<ST, DB> { ... }
}
Expand description

Represents a single database row.

This trait is used as an argument to FromSqlRow.

Required Associated Types§

Source

type Field<'f>: Field<'f, DB> where Self: 'f, 'a: 'f

Field type returned by a Row implementation

  • Crates using existing backends should not concern themself with the concrete type of this associated type.

  • Crates implementing custom backends should provide their own type meeting the required trait bounds

Source

type InnerPartialRow: Row<'a, DB>

Return type of PartialRow

For all implementations, beside of the Row implementation on PartialRow itself this should be Self.

Required Methods§

Source

fn field_count(&self) -> usize

Get the number of fields in the current row

Source

fn get<'b, I>(&'b self, idx: I) -> Option<Self::Field<'b>>
where Self: RowIndex<I>, 'a: 'b,

Get the field with the provided index from the row.

Returns None if there is no matching field for the given index

Source

fn partial_row( &self, range: Range<usize>, ) -> PartialRow<'_, Self::InnerPartialRow>

Returns a wrapping row that allows only to access fields, where the index is part of the provided range.

Provided Methods§

Source

fn get_value<ST, T, I>(&self, idx: I) -> Result<T>
where Self: RowIndex<I>, T: FromSql<ST, DB>,

Get a deserialized value with the provided index from the row.

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.

Implementors§

Source§

impl<'a, 'b, DB, R> Row<'a, DB> for PartialRow<'b, R>
where DB: Backend, R: Row<'a, DB>,

Source§

type Field<'f> = <R as Row<'a, DB>>::Field<'f> where R: 'f, Self: 'f, 'a: 'f

Source§

type InnerPartialRow = R