RowIteratorExt

Trait RowIteratorExt 

Source
pub trait RowIteratorExt: Iterator<Item = Result<Row, Error>> + Sized {
    // Required method
    fn map_rows<T: FromRow>(self) -> MapRows<Self, T> ;
}
Expand description

Extension trait for iterating over query results as typed structs.

This trait is automatically implemented for any iterator of Result<Row, Error>.

Required Methods§

Source

fn map_rows<T: FromRow>(self) -> MapRows<Self, T>

Map each row to a struct implementing FromRow.

§Example
use mssql_client::{FromRow, RowIteratorExt};

#[derive(FromRow)]
struct User { id: i32, name: String }

let users: Vec<User> = client
    .query("SELECT id, name FROM users", &[])
    .await?
    .map_rows::<User>()
    .collect::<Result<Vec<_>, _>>()?;

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§