From 7ab79d6de60f3aacf22c21b35a245fa9f74a6b0f Mon Sep 17 00:00:00 2001 From: Gwenael Treguier Date: Sun, 6 Dec 2015 19:57:20 +0100 Subject: [PATCH] Add Failure documentation. --- src/cache.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cache.rs b/src/cache.rs index 8724766..1b8141e 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -21,6 +21,10 @@ impl<'conn> StatementCache<'conn> { /// Search the cache for a prepared-statement object that implements `sql`. // If no such prepared-statement can be found, allocate and prepare a new one. + /// + /// # Failure + /// + /// Will return `Err` if no cached statement can be found and the underlying SQLite prepare call fails. pub fn get(&mut self, sql: &str) -> SqliteResult> { let stmt = self.cache.remove(sql); match stmt { @@ -32,11 +36,16 @@ impl<'conn> StatementCache<'conn> { /// If `discard` is true, then the statement is deleted immediately. /// Otherwise it is added to the LRU list and may be returned /// by a subsequent call to `get()`. + /// + /// # Failure + /// + /// Will return `Err` if `stmt` (or the already cached statement implementing the same SQL) statement is `discard`ed + /// and the underlying SQLite finalize call fails. pub fn release(&mut self, stmt: SqliteStatement<'conn>, discard: bool) -> SqliteResult<()> { if discard { return stmt.finalize(); } - // FIXME stmt.reset_if_needed(); + stmt.reset_if_needed(); // clear bindings ??? self.cache.insert(stmt.sql(), stmt).map_or(Ok(()), |stmt| stmt.finalize()) }