diff --git a/src/statement.rs b/src/statement.rs index 4fed850..0487115 100644 --- a/src/statement.rs +++ b/src/statement.rs @@ -49,6 +49,26 @@ impl<'l> Statement<'l> { value.bind(self, i) } + /// Return the number of columns. + #[inline] + pub fn columns(&self) -> usize { + unsafe { ffi::sqlite3_column_count(self.raw.0) as usize } + } + + /// Return the type of a column. + /// + /// The type is revealed after the first step has been taken. + pub fn kind(&self, i: usize) -> Type { + match unsafe { ffi::sqlite3_column_type(self.raw.0, i as c_int) } { + ffi::SQLITE_BLOB => Type::Binary, + ffi::SQLITE_FLOAT => Type::Float, + ffi::SQLITE_INTEGER => Type::Integer, + ffi::SQLITE_TEXT => Type::String, + ffi::SQLITE_NULL => Type::Null, + _ => unreachable!(), + } + } + /// Advance to the next state. /// /// The function should be called multiple times until `State::Done` is @@ -76,26 +96,6 @@ impl<'l> Statement<'l> { Ok(()) } - /// Return the number of columns. - #[inline] - pub fn columns(&self) -> usize { - unsafe { ffi::sqlite3_column_count(self.raw.0) as usize } - } - - /// Return the type of a column. - /// - /// The type is revealed after the first step has been taken. - pub fn kind(&self, i: usize) -> Type { - match unsafe { ffi::sqlite3_column_type(self.raw.0, i as c_int) } { - ffi::SQLITE_BLOB => Type::Binary, - ffi::SQLITE_FLOAT => Type::Float, - ffi::SQLITE_INTEGER => Type::Integer, - ffi::SQLITE_TEXT => Type::String, - ffi::SQLITE_NULL => Type::Null, - _ => unreachable!(), - } - } - /// Upgrade to a cursor. #[inline] pub fn cursor(self) -> Cursor<'l> {