mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-25 08:42:14 +00:00
Move a couple of functions
This commit is contained in:
parent
6c1ddbf184
commit
090deb80ac
@ -49,6 +49,26 @@ impl<'l> Statement<'l> {
|
|||||||
value.bind(self, i)
|
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.
|
/// Advance to the next state.
|
||||||
///
|
///
|
||||||
/// The function should be called multiple times until `State::Done` is
|
/// The function should be called multiple times until `State::Done` is
|
||||||
@ -76,26 +96,6 @@ impl<'l> Statement<'l> {
|
|||||||
Ok(())
|
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.
|
/// Upgrade to a cursor.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cursor(self) -> Cursor<'l> {
|
pub fn cursor(self) -> Cursor<'l> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user