mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Merge pull request #50 from gwenn/openflags
Make SqliteOpenFlags implement Default.
This commit is contained in:
commit
848065b922
14
src/lib.rs
14
src/lib.rs
@ -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> {
|
||||
|
Loading…
Reference in New Issue
Block a user