Function serde_rusqlite::from_row_with_columns
source · pub fn from_row_with_columns<D: DeserializeOwned>(
row: &Row<'_>,
columns: &[String]
) -> Result<D>
Expand description
Deserializes any instance of D: serde::Deserialize
from rusqlite::Row
with specified columns
Use this function over from_row()
to avoid allocation and overhead for fetching column names. To get columns names
you can use columns_from_statement()
.
You should use this function in the closure you supply to query_map()
.
Note: columns
is a slice of owned String
s to be type compatible with what columns_from_statement()
returns. Most of the time the result of that function will be used as the argument so it makes little sense
to accept something like &[impl AsRef<str>]
here. It will only make usage of the API less ergonomic. E.g.
There will be 2 generic type arguments to the from_row_with_columns()
instead of one.