From 9cac56d6a2cd3bf3fef0864675e2f0d4f67771c7 Mon Sep 17 00:00:00 2001 From: John Gallagher Date: Sat, 12 Dec 2015 14:13:29 -0500 Subject: [PATCH] Rename `SqliteOpenFlags` -> `OpenFlags`. --- Changelog.md | 1 + src/lib.rs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 85e04df..0a72e5e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ * `SqliteStatement` is now `Statement` * `SqliteRows` is now `Rows` * `SqliteRow` is now `Row` + * `SqliteOpenFlags` is now `OpenFlags` 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 `backup` feature that exposes SQLite's online backup API. diff --git a/src/lib.rs b/src/lib.rs index 2e7d78b..df6cc21 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,7 +232,7 @@ impl Connection { /// Will return `Err` if `path` cannot be converted to a C-compatible string or if the /// underlying SQLite open call fails. pub fn open_with_flags>(path: P, - flags: SqliteOpenFlags) + flags: OpenFlags) -> Result { let c_path = try!(path_to_cstring(path.as_ref())); InnerConnection::open_with_flags(&c_path, flags).map(|db| { @@ -251,7 +251,7 @@ impl Connection { /// # Failure /// /// Will return `Err` if the underlying SQLite open call fails. - pub fn open_in_memory_with_flags(flags: SqliteOpenFlags) -> Result { + pub fn open_in_memory_with_flags(flags: OpenFlags) -> Result { let c_memory = try!(str_to_cstring(":memory:")); InnerConnection::open_with_flags(&c_memory, flags).map(|db| { Connection { @@ -564,11 +564,14 @@ struct InnerConnection { db: *mut ffi::Struct_sqlite3, } +/// Old name for `OpenFlags`. `SqliteOpenFlags` is deprecated. +pub type SqliteOpenFlags = OpenFlags; + bitflags! { #[doc = "Flags for opening SQLite database connections."] #[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."] #[repr(C)] - flags SqliteOpenFlags: c_int { + flags OpenFlags: c_int { const SQLITE_OPEN_READ_ONLY = 0x00000001, const SQLITE_OPEN_READ_WRITE = 0x00000002, const SQLITE_OPEN_CREATE = 0x00000004, @@ -581,15 +584,15 @@ bitflags! { } } -impl Default for SqliteOpenFlags { - fn default() -> SqliteOpenFlags { +impl Default for OpenFlags { + fn default() -> OpenFlags { SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NO_MUTEX | SQLITE_OPEN_URI } } impl InnerConnection { fn open_with_flags(c_path: &CString, - flags: SqliteOpenFlags) + flags: OpenFlags) -> Result { unsafe { let mut db: *mut ffi::sqlite3 = mem::uninitialized(); @@ -1222,7 +1225,7 @@ mod test { #[test] fn test_open_with_flags() { - for bad_flags in [SqliteOpenFlags::empty(), + for bad_flags in [OpenFlags::empty(), SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_READ_WRITE, SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE] .iter() {