mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 19:41:37 +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;
|
extern crate libsqlite3_sys as ffi;
|
||||||
#[macro_use] extern crate bitflags;
|
#[macro_use] extern crate bitflags;
|
||||||
|
|
||||||
|
use std::default::Default;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
@ -160,13 +161,13 @@ impl SqliteConnection {
|
|||||||
/// `SqliteConnection::open(path)` is equivalent to `SqliteConnection::open_with_flags(path,
|
/// `SqliteConnection::open(path)` is equivalent to `SqliteConnection::open_with_flags(path,
|
||||||
/// SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)`.
|
/// SQLITE_OPEN_READ_WRITE | SQLITE_OPEN_CREATE)`.
|
||||||
pub fn open<P: AsRef<Path>>(path: &P) -> SqliteResult<SqliteConnection> {
|
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)
|
SqliteConnection::open_with_flags(path, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Open a new connection to an in-memory SQLite database.
|
/// Open a new connection to an in-memory SQLite database.
|
||||||
pub fn open_in_memory() -> SqliteResult<SqliteConnection> {
|
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)
|
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 {
|
impl InnerSqliteConnection {
|
||||||
fn open_with_flags(c_path: &CString, flags: SqliteOpenFlags)
|
fn open_with_flags(c_path: &CString, flags: SqliteOpenFlags)
|
||||||
-> SqliteResult<InnerSqliteConnection> {
|
-> SqliteResult<InnerSqliteConnection> {
|
||||||
|
Loading…
Reference in New Issue
Block a user