Rename SqliteOpenFlags -> OpenFlags.

This commit is contained in:
John Gallagher 2015-12-12 14:13:29 -05:00
parent ea5cb41bbf
commit 9cac56d6a2
2 changed files with 11 additions and 7 deletions

View File

@ -7,6 +7,7 @@
* `SqliteStatement` is now `Statement` * `SqliteStatement` is now `Statement`
* `SqliteRows` is now `Rows` * `SqliteRows` is now `Rows`
* `SqliteRow` is now `Row` * `SqliteRow` is now `Row`
* `SqliteOpenFlags` is now `OpenFlags`
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.

View File

@ -232,7 +232,7 @@ impl Connection {
/// Will return `Err` if `path` cannot be converted to a C-compatible string or if the /// Will return `Err` if `path` cannot be converted to a C-compatible string or if the
/// underlying SQLite open call fails. /// underlying SQLite open call fails.
pub fn open_with_flags<P: AsRef<Path>>(path: P, pub fn open_with_flags<P: AsRef<Path>>(path: P,
flags: SqliteOpenFlags) flags: OpenFlags)
-> Result<Connection> { -> Result<Connection> {
let c_path = try!(path_to_cstring(path.as_ref())); let c_path = try!(path_to_cstring(path.as_ref()));
InnerConnection::open_with_flags(&c_path, flags).map(|db| { InnerConnection::open_with_flags(&c_path, flags).map(|db| {
@ -251,7 +251,7 @@ impl Connection {
/// # Failure /// # Failure
/// ///
/// Will return `Err` if the underlying SQLite open call fails. /// Will return `Err` if the underlying SQLite open call fails.
pub fn open_in_memory_with_flags(flags: SqliteOpenFlags) -> Result<Connection> { pub fn open_in_memory_with_flags(flags: OpenFlags) -> Result<Connection> {
let c_memory = try!(str_to_cstring(":memory:")); let c_memory = try!(str_to_cstring(":memory:"));
InnerConnection::open_with_flags(&c_memory, flags).map(|db| { InnerConnection::open_with_flags(&c_memory, flags).map(|db| {
Connection { Connection {
@ -564,11 +564,14 @@ struct InnerConnection {
db: *mut ffi::Struct_sqlite3, db: *mut ffi::Struct_sqlite3,
} }
/// Old name for `OpenFlags`. `SqliteOpenFlags` is deprecated.
pub type SqliteOpenFlags = OpenFlags;
bitflags! { bitflags! {
#[doc = "Flags for opening SQLite database connections."] #[doc = "Flags for opening SQLite database connections."]
#[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."] #[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."]
#[repr(C)] #[repr(C)]
flags SqliteOpenFlags: c_int { flags OpenFlags: c_int {
const SQLITE_OPEN_READ_ONLY = 0x00000001, const SQLITE_OPEN_READ_ONLY = 0x00000001,
const SQLITE_OPEN_READ_WRITE = 0x00000002, const SQLITE_OPEN_READ_WRITE = 0x00000002,
const SQLITE_OPEN_CREATE = 0x00000004, const SQLITE_OPEN_CREATE = 0x00000004,
@ -581,15 +584,15 @@ bitflags! {
} }
} }
impl Default for SqliteOpenFlags { impl Default for OpenFlags {
fn default() -> SqliteOpenFlags { fn default() -> OpenFlags {
SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NO_MUTEX | SQLITE_OPEN_URI SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_NO_MUTEX | SQLITE_OPEN_URI
} }
} }
impl InnerConnection { impl InnerConnection {
fn open_with_flags(c_path: &CString, fn open_with_flags(c_path: &CString,
flags: SqliteOpenFlags) flags: OpenFlags)
-> Result<InnerConnection> { -> Result<InnerConnection> {
unsafe { unsafe {
let mut db: *mut ffi::sqlite3 = mem::uninitialized(); let mut db: *mut ffi::sqlite3 = mem::uninitialized();
@ -1222,7 +1225,7 @@ mod test {
#[test] #[test]
fn test_open_with_flags() { 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_READ_WRITE,
SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE] SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE]
.iter() { .iter() {