Skip to main content

ic_sqlite_vfs/
lib.rs

1//! IC canister crate root for the `icstable` SQLite VFS.
2//!
3//! The database image is stored inside a MemoryManager-compatible virtual
4//! memory. SQLite reaches it only through `sqlite3_vfs` callbacks, so no POSIX
5//! or WASI filesystem is used.
6
7#[cfg(all(feature = "sqlite-bundled", feature = "sqlite-precompiled"))]
8compile_error!("features `sqlite-bundled` and `sqlite-precompiled` cannot be enabled together");
9
10#[cfg(feature = "canister-api")]
11pub mod api;
12#[cfg(feature = "bench-profile")]
13#[doc(hidden)]
14pub mod bench_support;
15pub mod config;
16pub mod db;
17#[cfg(any(test, debug_assertions, feature = "bench-profile"))]
18#[doc(hidden)]
19mod read_metrics;
20#[doc(hidden)]
21mod sqlite_vfs;
22#[doc(hidden)]
23mod stable;
24#[cfg(any(test, debug_assertions))]
25#[doc(hidden)]
26pub mod test_support;
27
28pub use db::{Db, DbError, DbHandle};
29pub use stable::memory::{DbMemory, StableMemoryError};
30pub use stable::memory_manager::{MemoryId, MemoryManager, MemoryManagerInitError};
31pub use stable::raw_memory::DefaultMemoryImpl;
32
33#[macro_export]
34macro_rules! params {
35    () => {
36        &[]
37    };
38    ($($value:expr),+ $(,)?) => {
39        &[$($crate::db::value::to_sql_ref(&$value)),+]
40    };
41}
42
43#[macro_export]
44macro_rules! named_params {
45    () => {
46        &[]
47    };
48    ($($name:expr => $value:expr),+ $(,)?) => {
49        &[$(($name, $crate::db::value::to_sql_ref(&$value))),+]
50    };
51}
52
53#[cfg(feature = "canister-api")]
54use api::{ChecksumRefresh, DbMeta};
55
56#[cfg(feature = "canister-api")]
57ic_cdk::export_candid!();