diff options
author | David LeGare <legare@google.com> | 2022-03-02 16:21:10 +0000 |
---|---|---|
committer | David LeGare <legare@google.com> | 2022-03-02 16:21:10 +0000 |
commit | 82c86ae98e3b5c2b39a7372189bd093aab8b5a85 (patch) | |
tree | ed3dae2c91a4d67fe43675ec1ee9eaf437cd8280 /src/column.rs | |
parent | e3192e4d6dc62a821e1a759e53e0ae8016cea84e (diff) | |
download | rusqlite-82c86ae98e3b5c2b39a7372189bd093aab8b5a85.tar.gz |
Update rusqlite to 0.27.0
Test: cd external/rust/crates && atest --host -c
Change-Id: I70534db15d833dae7d254e1d772c1da6d35072ab
Diffstat (limited to 'src/column.rs')
-rw-r--r-- | src/column.rs | 82 |
1 files changed, 13 insertions, 69 deletions
diff --git a/src/column.rs b/src/column.rs index b9122c4..aa1f5f7 100644 --- a/src/column.rs +++ b/src/column.rs @@ -1,6 +1,6 @@ use std::str; -use crate::{Error, Result, Row, Rows, Statement}; +use crate::{Error, Result, Statement}; /// Information about a column of a SQLite query. #[derive(Debug)] @@ -12,12 +12,14 @@ pub struct Column<'stmt> { impl Column<'_> { /// Returns the name of the column. #[inline] + #[must_use] pub fn name(&self) -> &str { self.name } /// Returns the type of the column (`None` for expression). #[inline] + #[must_use] pub fn decl_type(&self) -> Option<&str> { self.decl_type } @@ -132,6 +134,7 @@ impl Statement<'_> { /// sure that current statement has already been stepped once before /// calling this method. #[cfg(feature = "column_decltype")] + #[cfg_attr(docsrs, doc(cfg(feature = "column_decltype")))] pub fn columns(&self) -> Vec<Column> { let n = self.column_count(); let mut cols = Vec::with_capacity(n as usize); @@ -147,72 +150,6 @@ impl Statement<'_> { } } -impl<'stmt> Rows<'stmt> { - /// Get all the column names. - #[inline] - pub fn column_names(&self) -> Option<Vec<&str>> { - self.stmt.map(Statement::column_names) - } - - /// Return the number of columns. - #[inline] - pub fn column_count(&self) -> Option<usize> { - self.stmt.map(Statement::column_count) - } - - /// Return the name of the column. - #[inline] - pub fn column_name(&self, col: usize) -> Option<Result<&str>> { - self.stmt.map(|stmt| stmt.column_name(col)) - } - - /// Return the index of the column. - #[inline] - pub fn column_index(&self, name: &str) -> Option<Result<usize>> { - self.stmt.map(|stmt| stmt.column_index(name)) - } - - /// Returns a slice describing the columns of the Rows. - #[inline] - #[cfg(feature = "column_decltype")] - pub fn columns(&self) -> Option<Vec<Column>> { - self.stmt.map(Statement::columns) - } -} - -impl<'stmt> Row<'stmt> { - /// Get all the column names of the Row. - #[inline] - pub fn column_names(&self) -> Vec<&str> { - self.stmt.column_names() - } - - /// Return the number of columns in the current row. - #[inline] - pub fn column_count(&self) -> usize { - self.stmt.column_count() - } - - /// Return the name of the column. - #[inline] - pub fn column_name(&self, col: usize) -> Result<&str> { - self.stmt.column_name(col) - } - - /// Return the index of the column. - #[inline] - pub fn column_index(&self, name: &str) -> Result<usize> { - self.stmt.column_index(name) - } - - /// Returns a slice describing the columns of the Row. - #[inline] - #[cfg(feature = "column_decltype")] - pub fn columns(&self) -> Vec<Column> { - self.stmt.columns() - } -} - #[cfg(test)] mod test { use crate::{Connection, Result}; @@ -230,10 +167,17 @@ mod test { column_names.as_slice(), &["type", "name", "tbl_name", "rootpage", "sql"] ); - let column_types: Vec<Option<&str>> = columns.iter().map(Column::decl_type).collect(); + let column_types: Vec<Option<String>> = columns + .iter() + .map(|col| col.decl_type().map(str::to_lowercase)) + .collect(); assert_eq!( &column_types[..3], - &[Some("text"), Some("text"), Some("text"),] + &[ + Some("text".to_owned()), + Some("text".to_owned()), + Some("text".to_owned()), + ] ); Ok(()) } |