Skip to content

Commit 0ff05f2

Browse files
committed
Rename Cursor to Statement
Introduces a more sensible name for this set of functionality and frees `Cursor` to be used for result sets.
1 parent 4576d65 commit 0ff05f2

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/sqlite3/database.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
** POSSIBILITY OF SUCH DAMAGE.
3030
*/
3131

32-
use cursor::*;
32+
use statement::*;
3333
use ffi::*;
3434
use libc::c_int;
3535
use std::ptr;
@@ -68,7 +68,7 @@ impl Database {
6868

6969
/// Prepares/compiles an SQL statement.
7070
/// See http://www.sqlite.org/c3ref/prepare.html
71-
pub fn prepare<'db>(&'db self, sql: &str, _tail: &Option<&str>) -> SqliteResult<Cursor<'db>> {
71+
pub fn prepare<'db>(&'db self, sql: &str, _tail: &Option<&str>) -> SqliteResult<Statement<'db>> {
7272
let new_stmt = ptr::null();
7373
let r = sql.with_c_str( |_sql| {
7474
unsafe {
@@ -77,7 +77,7 @@ impl Database {
7777
});
7878
if r == SQLITE_OK {
7979
debug!("`Database.prepare()`: stmt={:?}", new_stmt);
80-
Ok(Cursor::new(new_stmt, &self.dbh))
80+
Ok(Statement::new(new_stmt, &self.dbh))
8181
} else {
8282
Err(r)
8383
}

src/sqlite3/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
extern crate libc;
3838
extern crate collections;
3939

40-
pub use cursor::*;
40+
pub use statement::*;
4141
pub use database::*;
4242
use ffi::*;
4343
pub use types::*;
4444
use std::ptr;
4545

46-
pub mod cursor;
46+
pub mod statement;
4747
pub mod database;
4848
mod ffi;
4949

@@ -95,12 +95,12 @@ pub fn open(path: &str) -> SqliteResult<Database> {
9595

9696
#[cfg(test)]
9797
mod tests {
98-
use cursor::*;
98+
use statement::*;
9999
use database::*;
100100
use super::*;
101101
use types::*;
102102

103-
fn checked_prepare<'db>(database: &'db Database, sql: &str) -> Cursor<'db> {
103+
fn checked_prepare<'db>(database: &'db Database, sql: &str) -> Statement<'db> {
104104
match database.prepare(sql, &None) {
105105
Ok(s) => s,
106106
Err(x) => fail!(format!("sqlite error: \"{}\" ({:?})", database.get_errmsg(), x)),

src/sqlite3/cursor.rs renamed to src/sqlite3/statement.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ use std::str;
3636
use std::slice;
3737
use types::*;
3838

39-
/// The database cursor.
40-
pub struct Cursor<'db> {
39+
/// A prepared statement.
40+
pub struct Statement<'db> {
4141
stmt: *stmt,
4242
dbh: &'db *dbh
4343
}
4444

4545
#[unsafe_destructor]
46-
impl<'db> Drop for Cursor<'db> {
46+
impl<'db> Drop for Statement<'db> {
4747
/// Deletes a prepared SQL statement.
4848
/// See http://www.sqlite.org/c3ref/finalize.html
4949
fn drop(&mut self) {
50-
debug!("`Cursor.drop()`: stmt={:?}", self.stmt);
50+
debug!("`Statement.drop()`: stmt={:?}", self.stmt);
5151
unsafe {
5252
sqlite3_finalize(self.stmt);
5353
}
5454
}
5555
}
5656

57-
impl<'db> Cursor<'db> {
58-
pub fn new<'dbh>(stmt: *stmt, dbh: &'dbh *dbh) -> Cursor<'dbh> {
59-
debug!("`Cursor.new()`: stmt={:?}", stmt);
60-
Cursor { stmt: stmt, dbh: dbh }
57+
impl<'db> Statement<'db> {
58+
pub fn new<'dbh>(stmt: *stmt, dbh: &'dbh *dbh) -> Statement<'dbh> {
59+
debug!("`Statement.new()`: stmt={:?}", stmt);
60+
Statement { stmt: stmt, dbh: dbh }
6161
}
6262

6363
/// Resets a prepared SQL statement, but does not reset its bindings.
@@ -241,7 +241,7 @@ impl<'db> Cursor<'db> {
241241
/// See http://www.sqlite.org/c3ref/bind_blob.html
242242
pub fn bind_param(&self, i: int, value: &BindArg) -> ResultCode {
243243

244-
debug!("`Cursor.bind_param()`: stmt={:?}", self.stmt);
244+
debug!("`Statement.bind_param()`: stmt={:?}", self.stmt);
245245

246246
let r = match *value {
247247
Text(ref v) => {

0 commit comments

Comments
 (0)