From 2a8339bda7e5283a1eab7148bd2d576d9c2ac66b Mon Sep 17 00:00:00 2001 From: Pro Date: Thu, 22 Aug 2019 16:38:25 +0200 Subject: [PATCH] Forward all column related methods in Row and Rows --- src/column.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/column.rs b/src/column.rs index d21e8ee..8036f26 100644 --- a/src/column.rs +++ b/src/column.rs @@ -92,6 +92,16 @@ impl<'stmt> Rows<'stmt> { self.stmt.map(Statement::column_count) } + /// Return the name of the column. + pub fn column_name(&self, col: usize) -> Option<&str> { + self.stmt.and_then(|x| x.column_name(col)) + } + + /// Return the index of the column. + pub fn column_index(&self, name: &str) -> Option> { + self.stmt.map(|x| x.column_index(name)) + } + /// Returns a slice describing the columns of the Rows. pub fn columns(&self) -> Option>> { self.stmt.map(Statement::columns) @@ -99,11 +109,25 @@ impl<'stmt> Rows<'stmt> { } impl<'stmt> Row<'stmt> { + /// Get all the column names of the Row. + pub fn column_names(&self) -> Vec<&str> { + self.stmt.column_names() + } + /// Return the number of columns in the current row. pub fn column_count(&self) -> usize { self.stmt.column_count() } + /// Return the name of the column. + pub fn column_name(&self, col: usize) -> Option<&str> { + self.stmt.column_name(col) + } + + /// Return the index of the column. + pub fn column_index(&self, name: &str) -> Result { + self.stmt.column_index(name) + } /// Returns a slice describing the columns of the Row. pub fn columns(&self) -> Vec> { self.stmt.columns()