Move a couple of functions

This commit is contained in:
Ivan Ukhov 2017-08-23 10:18:50 +02:00
parent 6c1ddbf184
commit 090deb80ac

View File

@ -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> {