Make SqliteOpenFlags implement Default.

Activate URI and NO_MUTEX by default.
This commit is contained in:
gwenn 2015-07-06 20:24:27 +02:00
parent 255e5f0b68
commit fd36d98c85

View File

@ -54,6 +54,7 @@ extern crate libc;
extern crate libsqlite3_sys as ffi;
#[macro_use] extern crate bitflags;
use std::default::Default;
use std::mem;
use std::ptr;
use std::fmt;
@ -160,13 +161,13 @@ impl SqliteConnection {
/// `SqliteConnection::open(path)` is equivalent to `SqliteConnection::open_with_flags(path,
/// SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)`.
pub fn open<P: AsRef<Path>>(path: &P) -> SqliteResult<SqliteConnection> {
let flags = SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE;
let flags = Default::default();
SqliteConnection::open_with_flags(path, flags)
}
/// Open a new connection to an in-memory SQLite database.
pub fn open_in_memory() -> SqliteResult<SqliteConnection> {
let flags = SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE;
let flags = Default::default();
SqliteConnection::open_in_memory_with_flags(flags)
}
@ -435,6 +436,15 @@ bitflags! {
}
}
impl Default for SqliteOpenFlags {
fn default() -> SqliteOpenFlags {
SQLITE_OPEN_READ_WRITE
| SQLITE_OPEN_CREATE
| SQLITE_OPEN_NO_MUTEX
| SQLITE_OPEN_URI
}
}
impl InnerSqliteConnection {
fn open_with_flags(c_path: &CString, flags: SqliteOpenFlags)
-> SqliteResult<InnerSqliteConnection> {