mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-25 00:32:14 +00:00
move to rust 2018
This commit is contained in:
parent
a3ec52bbb9
commit
bd42e1b313
@ -21,6 +21,7 @@ repository = "https://github.com/stainless-steel/sqlite"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
categories = ["api-bindings", "database"]
|
categories = ["api-bindings", "database"]
|
||||||
keywords = ["database"]
|
keywords = ["database"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "marine_sqlite_connector"
|
name = "marine_sqlite_connector"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use sqlite3_connector as ffi;
|
use crate::sqlite3_connector as ffi;
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use {Result, Statement};
|
use crate::{Result, Statement};
|
||||||
|
|
||||||
/// A database connection.
|
/// A database connection.
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
@ -33,14 +33,14 @@ impl Connection {
|
|||||||
match result.ret_code {
|
match result.ret_code {
|
||||||
ffi::SQLITE_OK => {}
|
ffi::SQLITE_OK => {}
|
||||||
code => {
|
code => {
|
||||||
return match ::last_error(result.db_handle) {
|
return match crate::last_error(result.db_handle) {
|
||||||
Some(error) => {
|
Some(error) => {
|
||||||
ffi::sqlite3_close(result.db_handle);
|
ffi::sqlite3_close(result.db_handle);
|
||||||
Err(error)
|
Err(error)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
ffi::sqlite3_close(result.db_handle);
|
ffi::sqlite3_close(result.db_handle);
|
||||||
Err(::Error {
|
Err(crate::Error {
|
||||||
code: Some(code as isize),
|
code: Some(code as isize),
|
||||||
message: None,
|
message: None,
|
||||||
})
|
})
|
||||||
@ -91,7 +91,7 @@ impl Connection {
|
|||||||
/// Create a prepared statement.
|
/// Create a prepared statement.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement> {
|
pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement> {
|
||||||
::statement::new(self.raw, statement)
|
crate::statement::new(self.raw, statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the number of rows inserted, updated, or deleted by the most
|
/// Return the number of rows inserted, updated, or deleted by the most
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use sqlite3_connector as ffi;
|
use crate::sqlite3_connector as ffi;
|
||||||
use statement::{State, Statement};
|
use crate::statement::{State, Statement};
|
||||||
use {Result, Value};
|
use crate::{Result, Value};
|
||||||
|
|
||||||
/// An iterator over rows.
|
/// An iterator over rows.
|
||||||
pub struct Cursor {
|
pub struct Cursor {
|
||||||
|
@ -108,9 +108,9 @@ use std::{error, fmt};
|
|||||||
|
|
||||||
macro_rules! error(
|
macro_rules! error(
|
||||||
($connection:expr, $code:expr) => (
|
($connection:expr, $code:expr) => (
|
||||||
match ::last_error($connection) {
|
match crate::last_error($connection) {
|
||||||
Some(error) => return Err(error),
|
Some(error) => return Err(error),
|
||||||
_ => return Err(::Error {
|
_ => return Err(crate::Error {
|
||||||
code: Some($code as isize),
|
code: Some($code as isize),
|
||||||
message: None,
|
message: None,
|
||||||
}),
|
}),
|
||||||
@ -121,7 +121,7 @@ macro_rules! error(
|
|||||||
macro_rules! ok_descr(
|
macro_rules! ok_descr(
|
||||||
($connection:expr, $result:expr) => (
|
($connection:expr, $result:expr) => (
|
||||||
match $result.ret_code {
|
match $result.ret_code {
|
||||||
::ffi::SQLITE_OK => {}
|
crate::ffi::SQLITE_OK => {}
|
||||||
code => error!($connection, code),
|
code => error!($connection, code),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -139,7 +139,7 @@ macro_rules! ok_descr(
|
|||||||
macro_rules! ok_raw(
|
macro_rules! ok_raw(
|
||||||
($connection:expr, $result:expr) => (
|
($connection:expr, $result:expr) => (
|
||||||
match $result {
|
match $result {
|
||||||
::ffi::SQLITE_OK => {}
|
crate::ffi::SQLITE_OK => {}
|
||||||
code => error!($connection, code),
|
code => error!($connection, code),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use sqlite3_connector as ffi;
|
use crate::sqlite3_connector as ffi;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use {Cursor, Result, Type, Value};
|
use crate::{Cursor, Result, Type, Value};
|
||||||
|
|
||||||
/// A prepared statement.
|
/// A prepared statement.
|
||||||
pub struct Statement {
|
pub struct Statement {
|
||||||
@ -31,7 +31,7 @@ pub trait Readable: Sized {
|
|||||||
/// Read from a column.
|
/// Read from a column.
|
||||||
///
|
///
|
||||||
/// The leftmost column has the index 0.
|
/// The leftmost column has the index 0.
|
||||||
fn read(&Statement, usize) -> Result<Self>;
|
fn read(_: &Statement, _: usize) -> Result<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Statement {
|
impl Statement {
|
||||||
@ -108,7 +108,7 @@ impl Statement {
|
|||||||
/// Upgrade to a cursor.
|
/// Upgrade to a cursor.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn cursor(self) -> Cursor {
|
pub fn cursor(self) -> Cursor {
|
||||||
::cursor::new(self)
|
crate::cursor::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the raw pointer.
|
/// Return the raw pointer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user