1#![cfg_attr(any(feature = "embedded", target_os = "espidf"), no_std)]
2
3#[cfg(any(feature = "embedded", target_os = "espidf"))]
4extern crate alloc;
5
6pub mod error;
7pub mod migrations;
8
9#[cfg(all(feature = "web", target_arch = "wasm32"))]
10mod export_lock;
11#[cfg(all(feature = "web", target_arch = "wasm32"))]
12pub use export_lock::{
13 export_lock_active, export_lock_begin, export_lock_end, with_export_lock_bypass,
14};
15
16#[cfg(all(feature = "bridge", target_arch = "wasm32"))]
17mod executor_wasm;
18#[cfg(all(feature = "bridge", target_arch = "wasm32"))]
19pub use executor_wasm::WasmSqlExecutor;
20
21#[cfg(feature = "native")]
22mod executor_sqlite;
23#[cfg(feature = "native")]
24pub use executor_sqlite::SqliteExecutor;
25#[cfg(feature = "native")]
26pub mod sqlite_util;
27
28#[cfg(feature = "embedded")]
29mod executor_embedded;
30#[cfg(feature = "embedded")]
31pub use executor_embedded::EmbeddedSqlExecutor;
32
33#[cfg(not(any(feature = "embedded", target_os = "espidf")))]
34pub mod utils;
35
36pub use error::SqlError;
37
38#[derive(Clone, Copy, Debug)]
39pub struct ExecOutcome {
40 pub changes: i64,
41 pub last_insert_id: i64,
42}
43
44pub trait SqlExecutor: Send + Sync {
45 fn exec(&self, sql: &str, params_json: &str) -> Result<ExecOutcome, SqlError>;
46 fn query_raw(&self, sql: &str, params_json: &str) -> Result<String, SqlError>;
47 fn begin(&self) -> Result<(), SqlError>;
48 fn commit(&self) -> Result<(), SqlError>;
49 fn rollback(&self) -> Result<(), SqlError>;
50}