Add sqlite stub library

This commit is contained in:
lumi 2025-06-30 17:58:12 +10:00
parent 3de17cb77e
commit fc4d27abf1
Signed by: luaneko
GPG Key ID: 406809B8763FF07A
6 changed files with 119 additions and 1 deletions

66
Cargo.lock generated
View File

@ -579,6 +579,18 @@ dependencies = [
"windows-sys 0.60.2",
]
[[package]]
name = "fallible-iterator"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "fallible-streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "2.3.0"
@ -601,6 +613,12 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "form_urlencoded"
version = "1.2.1"
@ -740,6 +758,18 @@ name = "hashbrown"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
dependencies = [
"foldhash",
]
[[package]]
name = "hashlink"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
dependencies = [
"hashbrown 0.15.4",
]
[[package]]
name = "hdrhistogram"
@ -1062,6 +1092,15 @@ dependencies = [
"walkdir",
]
[[package]]
name = "lb_sqlite"
version = "0.0.1"
dependencies = [
"lb",
"luaffi",
"rusqlite",
]
[[package]]
name = "libc"
version = "0.2.174"
@ -1100,6 +1139,18 @@ dependencies = [
"libc",
]
[[package]]
name = "libsqlite3-sys"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91632f3b4fb6bd1d72aa3d78f41ffecfcf2b1a6648d8c241dbe7dbfaf4875e15"
dependencies = [
"bindgen",
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "libz-sys"
version = "1.1.22"
@ -1187,6 +1238,7 @@ dependencies = [
"clap",
"console-subscriber",
"lb",
"lb_sqlite",
"luajit",
"mimalloc",
"owo-colors",
@ -1554,6 +1606,20 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "rusqlite"
version = "0.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3de23c3319433716cf134eed225fe9986bc24f63bed9be9f20c329029e672dc7"
dependencies = [
"bitflags",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec",
]
[[package]]
name = "rustc-demangle"
version = "0.1.25"

View File

@ -2,6 +2,7 @@
resolver = "3"
members = [
"crates/lb",
"crates/lb_sqlite",
"crates/luaffi",
"crates/luaffi_impl",
"crates/luaify",
@ -35,17 +36,19 @@ name = "main"
harness = false
[features]
default = ["task", "time", "fs", "net"]
default = ["task", "time", "fs", "net", "sqlite"]
task = ["lb/task"]
time = ["lb/time"]
fs = ["lb/fs"]
net = ["lb/net"]
sqlite = ["dep:lb_sqlite"]
tokio-console = ["dep:console-subscriber"]
[dependencies]
clap = { version = "4.5.40", features = ["derive", "env"] }
console-subscriber = { version = "0.4.1", optional = true }
lb = { path = "crates/lb", features = ["runtime"] }
lb_sqlite = { path = "crates/lb_sqlite", optional = true }
luajit = { path = "crates/luajit", features = ["runtime"] }
mimalloc = "0.1.47"
owo-colors = "4.2.1"

View File

@ -0,0 +1,13 @@
[package]
name = "lb_sqlite"
version.workspace = true
edition.workspace = true
license.workspace = true
authors.workspace = true
homepage.workspace = true
repository.workspace = true
[dependencies]
lb = { path = "../lb", features = ["time"] }
luaffi = { version = "0.0.1", path = "../luaffi" }
rusqlite = { version = "0.36.0", features = ["bundled", "load_extension", "backup", "blob", "limits", "window", "series", "session", "collation", "serialize"] }

View File

@ -0,0 +1,3 @@
//! luby SQLite library.
#[path = "mod.rs"]
pub mod sqlite;

View File

@ -0,0 +1,27 @@
//! SQLite library.
//!
//! The `lb:sqlite` library provides an interface to SQLite databases.
//!
//! ## Exports
//!
//! See [`lb_sqlitelib`] for items exported by this library.
use luaffi::{cdef, metatype};
/// Items exported by the `lb:sqlite` library.
///
/// This library can be acquired by calling
/// [`require("lb:sqlite")`](https://www.lua.org/manual/5.1/manual.html#pdf-require).
///
/// ```lua
/// local sqlite = require("lb:sqlite");
/// ```
#[cdef(module = "lb:time")]
pub struct lb_sqlitelib;
#[metatype]
impl lb_sqlitelib {
#[new]
extern "Lua-C" fn new() -> Self {
Self
}
}

View File

@ -8,6 +8,9 @@ pub use lb::task;
#[cfg(feature = "time")]
pub use lb::time;
#[cfg(feature = "sqlite")]
pub use lb_sqlite::sqlite;
#[doc(hidden)]
pub fn open(#[allow(unused)] rt: &mut lb::runtime::Builder) {
#[cfg(feature = "task")]
@ -18,4 +21,7 @@ pub fn open(#[allow(unused)] rt: &mut lb::runtime::Builder) {
rt.module::<fs::lb_fslib>();
#[cfg(feature = "net")]
rt.module::<net::lb_netlib>();
#[cfg(feature = "sqlite")]
rt.module::<sqlite::lb_sqlitelib>();
}