Introduce Statement::columns

Return Columns name and type. (#494)
This commit is contained in:
gwenn
2019-03-19 20:33:36 +01:00
parent 1013571186
commit 38e92159fb
5 changed files with 150 additions and 46 deletions

View File

@@ -7,7 +7,7 @@ use crate::types::{FromSql, FromSqlError, ValueRef};
/// An handle for the resulting rows of a query.
pub struct Rows<'stmt> {
stmt: Option<&'stmt Statement<'stmt>>,
pub(crate) stmt: Option<&'stmt Statement<'stmt>>,
row: Option<Row<'stmt>>,
}
@@ -183,7 +183,7 @@ impl<'stmt> FallibleStreamingIterator for Rows<'stmt> {
/// A single result row of a query.
pub struct Row<'stmt> {
stmt: &'stmt Statement<'stmt>,
pub(crate) stmt: &'stmt Statement<'stmt>,
}
impl<'stmt> Row<'stmt> {
@@ -275,11 +275,6 @@ impl<'stmt> Row<'stmt> {
pub fn get_raw<I: RowIndex>(&self, idx: I) -> ValueRef<'_> {
self.get_raw_checked(idx).unwrap()
}
/// Return the number of columns in the current row.
pub fn column_count(&self) -> usize {
self.stmt.column_count()
}
}
/// A trait implemented by types that can index into columns of a row.