libsql_sys/lib.rs
1#![allow(clippy::too_many_arguments)]
2pub mod ffi {
3 //! C ffi for libsql.
4
5 pub use libsql_ffi::*;
6 use zerocopy::byteorder::big_endian::{U16 as bu16, U32 as bu32, U64 as bu64};
7
8 /// Patched database header file, in use by libsql
9 #[allow(dead_code)] // <- false positive
10 #[repr(C)]
11 #[derive(Clone, Copy, zerocopy::FromBytes, zerocopy::FromZeroes, zerocopy::AsBytes, Debug)]
12 pub struct Sqlite3DbHeader {
13 /// The header string: "SQLite format 3\000"
14 pub header_str: [u8; 16],
15 /// The database page size in bytes. Must be a power of two between 512 and 32768 inclusive, or the value 1 representing a page size of 65536.
16 pub page_size: bu16,
17 /// File format write version. 1 for legacy; 2 for WAL.
18 pub write_version: u8,
19 /// File format write version. 1 for legacy; 2 for WAL.
20 pub read_version: u8,
21 /// Bytes of unused "reserved" space at the end of each page. Usually 0.
22 pub reserved_in_page: u8,
23 /// Maximum embedded payload fraction. Must be 64.
24 pub max_payload: u8,
25 /// Minimum embedded payload fraction. Must be 32.
26 pub min_payload: u8,
27 /// Leaf payload fraction. Must be 32.
28 pub leaf_payload: u8,
29 /// File change counter.
30 pub change_count: bu32,
31 /// Size of the database file in pages. The "in-header database size".
32 pub db_size: bu32,
33 /// Page number of the first freelist trunk page.
34 pub freelist_pno: bu32,
35 /// Total number of freelist pages.
36 pub freelist_len: bu32,
37 /// The schema cookie.
38 pub schema_cookie: bu32,
39 /// The schema format number. Supported schema formats are 1, 2, 3, and 4.
40 pub schema_format_number: bu32,
41 /// Default page cache size.
42 pub default_cache_size: bu32,
43 /// The page number of the largest root b-tree page when in auto-vacuum or incremental-vacuum modes, or zero otherwise.
44 pub largest_root: bu32,
45 /// The database text encoding. A value of 1 means UTF-8. A value of 2 means UTF-16le. A value of 3 means UTF-16be.
46 pub text_encoding: bu32,
47 /// The "user version" as read and set by the user_version pragma.
48 pub user_version: bu32,
49 /// True (non-zero) for incremental-vacuum mode. False (zero) otherwise.
50 pub incremental_vacuum: bu32,
51 /// The "Application ID" set by PRAGMA application_id.
52 pub app_id: bu32,
53 /// Reserved for expansion. Must be zero.
54 _reserved: [u8; 12],
55 /// The replication index of this database, this is a libsql extension, ignored by sqlite3.
56 pub replication_index: bu64,
57 /// The version-valid-for number.
58 pub version_valid_for: bu32,
59 /// SQLITE_VERSION_NUMBER
60 pub sqlite_version: bu32,
61 }
62}
63
64#[cfg(feature = "api")]
65pub mod connection;
66pub mod error;
67pub mod name;
68#[cfg(feature = "api")]
69pub mod statement;
70#[cfg(feature = "api")]
71pub mod types;
72#[cfg(feature = "api")]
73pub mod value;
74#[cfg(feature = "wal")]
75pub mod wal;
76
77#[cfg(feature = "api")]
78pub use connection::Cipher;
79#[cfg(feature = "api")]
80pub use connection::Connection;
81#[cfg(feature = "api")]
82pub use connection::EncryptionConfig;
83#[cfg(feature = "api")]
84pub use error::{Error, Result};
85#[cfg(feature = "api")]
86pub use statement::{prepare_stmt, Statement};
87#[cfg(feature = "api")]
88pub use types::*;
89#[cfg(feature = "api")]
90pub use value::{Value, ValueType};
91
92#[cfg(feature = "rusqlite")]
93pub use rusqlite;