mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +08:00
Rename SqliteRows
-> Rows
.
This commit is contained in:
parent
ec654352d9
commit
b932640181
@ -5,6 +5,7 @@
|
|||||||
* `SqliteError` is now `Error`
|
* `SqliteError` is now `Error`
|
||||||
* `SqliteResult` is now `Result`
|
* `SqliteResult` is now `Result`
|
||||||
* `SqliteStatement` is now `Statement`
|
* `SqliteStatement` is now `Statement`
|
||||||
|
* `SqliteRows` is now `Rows`
|
||||||
The old, prefixed names are still exported should be considered deprecated.
|
The old, prefixed names are still exported should be considered deprecated.
|
||||||
* Adds a variety of `..._named` methods for executing queries using named placeholder parameters.
|
* Adds a variety of `..._named` methods for executing queries using named placeholder parameters.
|
||||||
* Adds `backup` feature that exposes SQLite's online backup API.
|
* Adds `backup` feature that exposes SQLite's online backup API.
|
||||||
|
23
src/lib.rs
23
src/lib.rs
@ -841,7 +841,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// # Failure
|
/// # Failure
|
||||||
///
|
///
|
||||||
/// Will return `Err` if binding parameters fails.
|
/// Will return `Err` if binding parameters fails.
|
||||||
pub fn query<'a>(&'a mut self, params: &[&ToSql]) -> Result<SqliteRows<'a>> {
|
pub fn query<'a>(&'a mut self, params: &[&ToSql]) -> Result<Rows<'a>> {
|
||||||
self.reset_if_needed();
|
self.reset_if_needed();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
@ -849,7 +849,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.needs_reset = true;
|
self.needs_reset = true;
|
||||||
Ok(SqliteRows::new(self))
|
Ok(Rows::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the prepared statement and maps a function over the resulting
|
/// Executes the prepared statement and maps a function over the resulting
|
||||||
@ -964,7 +964,7 @@ impl<'conn> Drop for Statement<'conn> {
|
|||||||
|
|
||||||
/// An iterator over the mapped resulting rows of a query.
|
/// An iterator over the mapped resulting rows of a query.
|
||||||
pub struct MappedRows<'stmt, F> {
|
pub struct MappedRows<'stmt, F> {
|
||||||
rows: SqliteRows<'stmt>,
|
rows: Rows<'stmt>,
|
||||||
map: F,
|
map: F,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,7 +980,7 @@ impl<'stmt, T, F> Iterator for MappedRows<'stmt, F> where F: FnMut(&SqliteRow) -
|
|||||||
/// An iterator over the mapped resulting rows of a query, with an Error type
|
/// An iterator over the mapped resulting rows of a query, with an Error type
|
||||||
/// unifying with Error.
|
/// unifying with Error.
|
||||||
pub struct AndThenRows<'stmt, F> {
|
pub struct AndThenRows<'stmt, F> {
|
||||||
rows: SqliteRows<'stmt>,
|
rows: Rows<'stmt>,
|
||||||
map: F,
|
map: F,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,12 +998,15 @@ where E: convert::From<Error>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Old name for `Rows`. `SqliteRows` is deprecated.
|
||||||
|
pub type SqliteRows<'stmt> = Rows<'stmt>;
|
||||||
|
|
||||||
/// An iterator over the resulting rows of a query.
|
/// An iterator over the resulting rows of a query.
|
||||||
///
|
///
|
||||||
/// ## Warning
|
/// ## Warning
|
||||||
///
|
///
|
||||||
/// Due to the way SQLite returns result rows of a query, it is not safe to attempt to get values
|
/// Due to the way SQLite returns result rows of a query, it is not safe to attempt to get values
|
||||||
/// from a row after it has become stale (i.e., `next()` has been called again on the `SqliteRows`
|
/// from a row after it has become stale (i.e., `next()` has been called again on the `Rows`
|
||||||
/// iterator). For example:
|
/// iterator). For example:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
@ -1033,15 +1036,15 @@ where E: convert::From<Error>,
|
|||||||
/// no longer implement `Iterator`, and therefore you would lose access to the majority of
|
/// no longer implement `Iterator`, and therefore you would lose access to the majority of
|
||||||
/// functions which are useful (such as support for `for ... in ...` looping, `map`, `filter`,
|
/// functions which are useful (such as support for `for ... in ...` looping, `map`, `filter`,
|
||||||
/// etc.).
|
/// etc.).
|
||||||
pub struct SqliteRows<'stmt> {
|
pub struct Rows<'stmt> {
|
||||||
stmt: &'stmt Statement<'stmt>,
|
stmt: &'stmt Statement<'stmt>,
|
||||||
current_row: Rc<Cell<c_int>>,
|
current_row: Rc<Cell<c_int>>,
|
||||||
failed: bool,
|
failed: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'stmt> SqliteRows<'stmt> {
|
impl<'stmt> Rows<'stmt> {
|
||||||
fn new(stmt: &'stmt Statement<'stmt>) -> SqliteRows<'stmt> {
|
fn new(stmt: &'stmt Statement<'stmt>) -> Rows<'stmt> {
|
||||||
SqliteRows {
|
Rows {
|
||||||
stmt: stmt,
|
stmt: stmt,
|
||||||
current_row: Rc::new(Cell::new(0)),
|
current_row: Rc::new(Cell::new(0)),
|
||||||
failed: false,
|
failed: false,
|
||||||
@ -1061,7 +1064,7 @@ impl<'stmt> SqliteRows<'stmt> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'stmt> Iterator for SqliteRows<'stmt> {
|
impl<'stmt> Iterator for Rows<'stmt> {
|
||||||
type Item = Result<SqliteRow<'stmt>>;
|
type Item = Result<SqliteRow<'stmt>>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Result<SqliteRow<'stmt>>> {
|
fn next(&mut self) -> Option<Result<SqliteRow<'stmt>>> {
|
||||||
|
@ -2,7 +2,7 @@ use libc::c_int;
|
|||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
|
|
||||||
use {Result, Error, Connection, Statement, SqliteRows, SqliteRow, str_to_cstring};
|
use {Result, Error, Connection, Statement, Rows, SqliteRow, str_to_cstring};
|
||||||
use types::ToSql;
|
use types::ToSql;
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
@ -104,7 +104,7 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use rusqlite::{Connection, Result, SqliteRows};
|
/// # use rusqlite::{Connection, Result, Rows};
|
||||||
/// fn query(conn: &Connection) -> Result<()> {
|
/// fn query(conn: &Connection) -> Result<()> {
|
||||||
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
|
/// let mut stmt = try!(conn.prepare("SELECT * FROM test where name = :name"));
|
||||||
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));
|
/// let mut rows = try!(stmt.query_named(&[(":name", &"one")]));
|
||||||
@ -120,12 +120,12 @@ impl<'conn> Statement<'conn> {
|
|||||||
/// Will return `Err` if binding parameters fails.
|
/// Will return `Err` if binding parameters fails.
|
||||||
pub fn query_named<'a>(&'a mut self,
|
pub fn query_named<'a>(&'a mut self,
|
||||||
params: &[(&str, &ToSql)])
|
params: &[(&str, &ToSql)])
|
||||||
-> Result<SqliteRows<'a>> {
|
-> Result<Rows<'a>> {
|
||||||
self.reset_if_needed();
|
self.reset_if_needed();
|
||||||
try!(self.bind_parameters_named(params));
|
try!(self.bind_parameters_named(params));
|
||||||
|
|
||||||
self.needs_reset = true;
|
self.needs_reset = true;
|
||||||
Ok(SqliteRows::new(self))
|
Ok(Rows::new(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_parameters_named(&mut self, params: &[(&str, &ToSql)]) -> Result<()> {
|
fn bind_parameters_named(&mut self, params: &[(&str, &ToSql)]) -> Result<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user