mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-06-24 04:21:32 +00:00
Make execute and statement take immutable self
This commit is contained in:
@ -25,8 +25,8 @@ impl Database {
|
||||
}
|
||||
|
||||
/// Execute an SQL statement.
|
||||
pub fn execute<'l>(&mut self, sql: &str,
|
||||
callback: Option<&mut ExecuteCallback<'l>>) -> Result<()> {
|
||||
pub fn execute<'l>(&self, sql: &str, callback: Option<&mut ExecuteCallback<'l>>)
|
||||
-> Result<()> {
|
||||
|
||||
unsafe {
|
||||
match callback {
|
||||
@ -49,7 +49,7 @@ impl Database {
|
||||
|
||||
/// Create a prepared statement.
|
||||
#[inline]
|
||||
pub fn statement<'l>(&'l mut self, sql: &str) -> Result<Statement<'l>> {
|
||||
pub fn statement<'l>(&'l self, sql: &str) -> Result<Statement<'l>> {
|
||||
::statement::new(self, sql)
|
||||
}
|
||||
}
|
||||
@ -62,7 +62,7 @@ impl Drop for Database {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_raw(database: &mut Database) -> *mut raw::sqlite3 {
|
||||
pub fn as_raw(database: &Database) -> *mut raw::sqlite3 {
|
||||
database.raw
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub struct Error {
|
||||
|
||||
impl Error {
|
||||
/// Return the last occurred error if any.
|
||||
pub fn last(database: &mut Database) -> Option<Error> {
|
||||
pub fn last(database: &Database) -> Option<Error> {
|
||||
unsafe {
|
||||
let code = raw::sqlite3_errcode(::database::as_raw(database));
|
||||
if code == raw::SQLITE_OK {
|
||||
|
@ -101,7 +101,7 @@ impl Value for String {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new<'l>(database: &'l mut Database, sql: &str) -> Result<Statement<'l>> {
|
||||
pub fn new<'l>(database: &'l Database, sql: &str) -> Result<Statement<'l>> {
|
||||
let mut raw = 0 as *mut _;
|
||||
unsafe {
|
||||
success!(database, raw::sqlite3_prepare(::database::as_raw(database), str_to_c_str!(sql),
|
||||
|
Reference in New Issue
Block a user