Rename SqliteLoadExtensionGuard -> LoadExtensionGuard.

This commit is contained in:
John Gallagher 2015-12-12 14:20:11 -05:00
parent 3d15a8a15c
commit b1cde705be
3 changed files with 16 additions and 12 deletions

View File

@ -10,6 +10,7 @@
* `SqliteOpenFlags` is now `OpenFlags`
* `SqliteTransaction` is now `Transaction`.
* `SqliteTransactionBehavior` is now `TransactionBehavior`.
* `SqliteLoadExtensionGuard` is now `LoadExtensionGuard`.
The old, prefixed names are still exported but are deprecated.
* Adds a variety of `..._named` methods for executing queries using named placeholder parameters.
* Adds `backup` feature that exposes SQLite's online backup API.

View File

@ -74,12 +74,12 @@ use libc::{c_int, c_void, c_char};
use types::{ToSql, FromSql};
pub use transaction::Transaction;
pub use transaction::{SqliteTransaction, Transaction};
pub use transaction::{TransactionBehavior, TransactionDeferred,
TransactionImmediate, TransactionExclusive};
#[cfg(feature = "load_extension")]
pub use load_extension_guard::SqliteLoadExtensionGuard;
pub use load_extension_guard::{SqliteLoadExtensionGuard, LoadExtensionGuard};
pub mod types;
mod transaction;
@ -478,7 +478,7 @@ impl Connection {
db.close()
}
/// Enable loading of SQLite extensions. Strongly consider using `SqliteLoadExtensionGuard`
/// Enable loading of SQLite extensions. Strongly consider using `LoadExtensionGuard`
/// instead of this function.
///
/// ## Example
@ -523,10 +523,10 @@ impl Connection {
/// ## Example
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result, SqliteLoadExtensionGuard};
/// # use rusqlite::{Connection, Result, LoadExtensionGuard};
/// # use std::path::{Path};
/// fn load_my_extension(conn: &Connection) -> Result<()> {
/// let _guard = try!(SqliteLoadExtensionGuard::new(conn));
/// let _guard = try!(LoadExtensionGuard::new(conn));
///
/// conn.load_extension("my_sqlite_extension", None)
/// }

View File

@ -1,32 +1,35 @@
use {Result, Connection};
/// Old name for `LoadExtensionGuard`. `SqliteLoadExtensionGuard` is deprecated.
pub type SqliteLoadExtensionGuard<'conn> = LoadExtensionGuard<'conn>;
/// RAII guard temporarily enabling SQLite extensions to be loaded.
///
/// ## Example
///
/// ```rust,no_run
/// # use rusqlite::{Connection, Result, SqliteLoadExtensionGuard};
/// # use rusqlite::{Connection, Result, LoadExtensionGuard};
/// # use std::path::{Path};
/// fn load_my_extension(conn: &Connection) -> Result<()> {
/// let _guard = try!(SqliteLoadExtensionGuard::new(conn));
/// let _guard = try!(LoadExtensionGuard::new(conn));
///
/// conn.load_extension(Path::new("my_sqlite_extension"), None)
/// }
/// ```
pub struct SqliteLoadExtensionGuard<'conn> {
pub struct LoadExtensionGuard<'conn> {
conn: &'conn Connection,
}
impl<'conn> SqliteLoadExtensionGuard<'conn> {
impl<'conn> LoadExtensionGuard<'conn> {
/// Attempt to enable loading extensions. Loading extensions will be disabled when this
/// guard goes out of scope. Cannot be meaningfully nested.
pub fn new(conn: &Connection) -> Result<SqliteLoadExtensionGuard> {
conn.load_extension_enable().map(|_| SqliteLoadExtensionGuard { conn: conn })
pub fn new(conn: &Connection) -> Result<LoadExtensionGuard> {
conn.load_extension_enable().map(|_| LoadExtensionGuard { conn: conn })
}
}
#[allow(unused_must_use)]
impl<'conn> Drop for SqliteLoadExtensionGuard<'conn> {
impl<'conn> Drop for LoadExtensionGuard<'conn> {
fn drop(&mut self) {
self.conn.load_extension_disable();
}