Skip to main content

cartel_sqlite/runtime/
mod.rs

1use dope_core::driver::schedule::clock::timer;
2use o3::alloc;
3use std::mem;
4
5pub(crate) mod heap;
6mod layout;
7pub mod local;
8pub mod raw;
9mod release;
10pub(crate) mod slot;
11
12pub use layout::Layout;
13
14/// Proof that process-wide SQLite configuration is installed.
15#[derive(Clone, Copy, PartialEq, Eq)]
16pub struct Runtime(());
17
18impl Runtime {
19    /// Installs private native caches with a 20-page initial batch before workers start.
20    /// Requires writable static data and no statement logging or statement virtual table.
21    /// Build with `LIBSQLITE3_FLAGS=-USQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS`.
22    pub fn install(permit: raw::Permit) -> Result<Self, Error> {
23        let raw::Permit(()) = permit.initialize()?;
24        Ok(Self(()))
25    }
26}
27
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
29pub enum Error {
30    /// The native build shares page-cache allocations between connection arenas.
31    GlobalCache,
32    /// The native build retains unused global page-cache allocation statistics.
33    CacheStats,
34    /// The native statement virtual table measures memory after execution.
35    StatementVtab,
36    /// The native build emulates writable static data with fallible initialization.
37    WritableStatic,
38    /// The native SQL log can expand borrowed bindings during statement cleanup.
39    StatementLog,
40    Threading(crate::Code),
41    Initialization(crate::Code),
42    VfsMissing,
43    VfsOpen,
44    VfsFileSize {
45        actual: std::ffi::c_int,
46    },
47    VfsRegistration(crate::Code),
48    SqliteBytes,
49    SqliteCapacity,
50    /// Usable heap bytes exceed SQLite's signed statement memory counter.
51    SqliteMemory {
52        actual: usize,
53    },
54    StatementSqlBytes {
55        actual: usize,
56    },
57    CapacityOverflow,
58    Allocation(alloc::Error),
59    Layout,
60    TimerCapacity(timer::Exhausted),
61}
62
63const _: () = assert!(mem::size_of::<Runtime>() == 0);