1
1
//! Rows.
2
2
3
3
use crate :: row:: sealed:: { AsName , Sealed } ;
4
+ use crate :: simple_query:: SimpleColumn ;
4
5
use crate :: statement:: Column ;
5
6
use crate :: types:: { FromSql , Type , WrongType } ;
6
7
use crate :: { Error , Statement } ;
@@ -188,16 +189,25 @@ impl Row {
188
189
}
189
190
}
190
191
192
+ impl AsName for SimpleColumn {
193
+ fn as_name ( & self ) -> & str {
194
+ self . name ( )
195
+ }
196
+ }
197
+
191
198
/// A row of data returned from the database by a simple query.
192
199
pub struct SimpleQueryRow {
193
- columns : Arc < [ String ] > ,
200
+ columns : Arc < [ SimpleColumn ] > ,
194
201
body : DataRowBody ,
195
202
ranges : Vec < Option < Range < usize > > > ,
196
203
}
197
204
198
205
impl SimpleQueryRow {
199
206
#[ allow( clippy:: new_ret_no_self) ]
200
- pub ( crate ) fn new ( columns : Arc < [ String ] > , body : DataRowBody ) -> Result < SimpleQueryRow , Error > {
207
+ pub ( crate ) fn new (
208
+ columns : Arc < [ SimpleColumn ] > ,
209
+ body : DataRowBody ,
210
+ ) -> Result < SimpleQueryRow , Error > {
201
211
let ranges = body. ranges ( ) . collect ( ) . map_err ( Error :: parse) ?;
202
212
Ok ( SimpleQueryRow {
203
213
columns,
@@ -206,6 +216,11 @@ impl SimpleQueryRow {
206
216
} )
207
217
}
208
218
219
+ /// Returns information about the columns of data in the row.
220
+ pub fn columns ( & self ) -> & [ SimpleColumn ] {
221
+ & self . columns
222
+ }
223
+
209
224
/// Determines if the row contains no values.
210
225
pub fn is_empty ( & self ) -> bool {
211
226
self . len ( ) == 0
0 commit comments