On MSVC targets, the `turso_sdk_kit` build script looks for `rc.exe` only in `PATH` and under `%ProgramFiles(x86)%\Windows Kits\10\bin`. If the Windows SDK is installed anywhere else (mine is in `D:\Windows Kits\10`), the build panics: ``` rc.exe was not found in PATH and Windows SDK bin directory C:\Program Files (x86)\Windows Kits\10\bin could not be read: The system cannot find the path specified. (os error 3) ``` This breaks any project that pulls in `turso` on Windows, even as a transitive dependency. I ran into it through `cubecl` (used by `burn`), which uses `turso` for its on-disk cache. This change keeps the `PATH` lookup. If that fails, the script now gets the SDK location from `find_msvc_tools::find_windows_sdk`, which reads it from the registry the same way `cc` does, and looks for `rc.exe` in the SDK's bin directories for the host architecture. The registry also points to the default install location, so I removed the old Program Files lookup. `find-msvc-tools` is already in `Cargo.lock` through `cc`, so nothing new gets downloaded. I added its licenses and a NOTICE entry as described in CONTRIBUTING.md. This doesn't touch the `windres` path for GNU targets, which is a separate problem (#8689). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Closes #9500
Turso SDK kit
Building a Rust application? Use the
tursocrate instead. This crate is the low-level C ABI used to build language bindings; it is not the Rust SDK for end users.
Low-level, SQLite-compatible Turso API to make building SDKs in any language simple and predictable. The core logic is implemented in Rust and exposed through a small, portable C ABI (turso.h), so you can generate language bindings (e.g. via rust-bindgen) without re-implementing database semantics.
Key ideas:
- Async I/O: opt-in caller-driven I/O (ideal for event loops or io_uring), or library-driven I/O.
- Clear status codes: Done/Row/Io/Error/etc. No hidden blocking or exceptions.
- Minimal surface: open database, connect, prepare, bind, step/execute, read rows, finalize.
- Ownership model and lifetimes are explicit for C consumers.
- Optional page codecs: callers can provide a synchronous page transform callback table to decode/encode legacy encrypted database pages without linking that crypto into Turso core.
Note: turso.h is the single C header exported by the crate and can be translated to bindings.rs with rust-bindgen.
External page codecs
turso_database_config_t.page_codec accepts a versioned turso_page_codec_v1_t callback table. The callbacks transform complete page images between on-disk bytes and plaintext SQLite pages. They are intended for compatibility layers such as legacy SQLite codec formats where the application supplies the crypto implementation.
Codec rules:
- callbacks are synchronous and must not perform Turso I/O or re-enter the same database;
probe_headermay inspect the raw first 512 bytes and report page size/reserved bytes before Turso parses page 1;decode_pageandencode_pagereceive a page number and location (DATABASEorWAL) and must write exactly one page to the output buffer;codec_idmust be a stable, non-secret identifier for the codec configuration and must change whenever the page transform could produce different bytes;- the callback context and function pointers must remain valid until the codec
destroycallback is invoked; - callback failures are surfaced as database open/read/write errors.
Language bindings can expose this generic surface by wrapping turso_page_codec_v1_t
with binding-specific lifetime management for the callback context.
Rust example
use turso_sdk_kit::rsapi::{
TursoDatabase, TursoDatabaseConfig, TursoStatusCode, Value, ValueRef,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create the database holder (not opened yet).
let db = TursoDatabase::create(TursoDatabaseConfig {
path: ":memory:".to_string(),
experimental_features: None,
io: None,
// When true, step/execute may return Io and you should call run_io() to progress.
async_io: true,
});
// Open and connect.
db.open()?;
let conn = db.connect()?;
// Prepare, bind, and step a simple query.
let mut stmt = conn.prepare_single("SELECT :greet || ' Turso'")?;
stmt.bind_named("greet", Value::Text("Hello".into()))?;
loop {
match stmt.step()? {
TursoStatusCode::Row => {
// Read current row value. Valid until next step/reset/finalize.
match stmt.row_value(0)? {
ValueRef::Text(t) => println!("{}", t.as_str()),
other => println!("row[0] = {:?}", other),
}
}
TursoStatusCode::Io => {
// Drive one iteration of the I/O backend.
stmt.run_io()?;
}
TursoStatusCode::Done => break,
_ => unreachable!("unexpected status"),
}
}
// Finalize to complete the statement cleanly (may also return Io).
match stmt.finalize()? {
TursoStatusCode::Io => {
// If needed, drive IO and finalize again.
stmt.run_io()?;
let _ = stmt.finalize()?;
}
_ => {}
}
Ok(())
}
C example
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "turso.h"
static void fail_and_cleanup(const char *msg, turso_status_t st) {
fprintf(stderr, "%s: %s\n", msg, st.error ? st.error : "(no message)");
if (st.error) turso_status_deinit(st);
}
int main(void) {
// Optional: initialize logging (stdout example) and/or set log level via environment.
// turso_setup((turso_config_t){ .logger = NULL, .log_level = "info" });
// Create database holder (not opened yet). Enable caller-driven async I/O.
turso_database_create_result_t db_res = turso_database_create(
(turso_database_config_t){
.path = ":memory:",
.experimental_features = NULL,
.async_io = true,
}
);
if (db_res.status.code != TURSO_OK) {
fail_and_cleanup("create database failed", db_res.status);
return 1;
}
turso_status_t st = turso_database_open(db_res.database);
if (st.code != TURSO_OK) {
fail_and_cleanup("open failed", st);
turso_database_deinit(db_res.database);
return 1;
}
turso_database_connect_result_t conn_res = turso_database_connect(db_res.database);
if (conn_res.status.code != TURSO_OK) {
fail_and_cleanup("connect failed", conn_res.status);
turso_database_deinit(db_res.database);
return 1;
}
const char *sql = "SELECT :greet || ' Turso'";
turso_connection_prepare_single_t prep =
turso_connection_prepare_single(
conn_res.connection,
(turso_slice_ref_t){ .ptr = (const void*)sql, .len = strlen(sql) });
if (prep.status.code != TURSO_OK) {
fail_and_cleanup("prepare failed", prep.status);
turso_connection_deinit(conn_res.connection);
turso_database_deinit(db_res.database);
return 1;
}
// Bind named parameter (omit the leading ':' in the name).
const char *name = "greet";
const char *val = "Hello";
st = turso_statement_bind_named(
prep.statement,
(turso_slice_ref_t){ .ptr = (const void*)name, .len = strlen(name) },
turso_text(val, strlen(val))
);
if (st.code != TURSO_OK) {
fail_and_cleanup("bind failed", st);
turso_statement_deinit(prep.statement);
turso_connection_deinit(conn_res.connection);
turso_database_deinit(db_res.database);
return 1;
}
// Drive the statement: handle ROW/IO/DONE.
for (;;) {
turso_status_t step = turso_statement_step(prep.statement);
if (step.code == TURSO_IO) {
// Run one iteration of the IO backend and continue.
turso_status_t io = turso_statement_run_io(prep.statement);
if (io.code != TURSO_OK) {
fail_and_cleanup("run_io failed", io);
break;
}
continue;
}
if (step.code == TURSO_ROW) {
turso_statement_row_value_t rv = turso_statement_row_value(prep.statement, 0);
if (rv.status.code == TURSO_OK && rv.value.type == TURSO_TYPE_TEXT) {
const turso_slice_ref_t s = rv.value.value.text;
fwrite(s.ptr, 1, s.len, stdout);
fputc('\n', stdout);
}
continue;
}
if (step.code == TURSO_DONE) {
break;
}
// Any other status is an error.
fail_and_cleanup("step failed", step);
break;
}
// Finalize; if it returns TURSO_IO, drive IO until OK.
for (;;) {
turso_status_t fin = turso_statement_finalize(prep.statement);
if (fin.code == TURSO_OK) break;
if (fin.code == TURSO_IO) {
turso_status_t io = turso_statement_run_io(prep.statement);
if (io.code != TURSO_OK) { fail_and_cleanup("finalize run_io failed", io); break; }
continue;
}
fail_and_cleanup("finalize failed", fin);
break;
}
// Clean up handles.
turso_statement_deinit(prep.statement);
turso_connection_deinit(conn_res.connection);
turso_database_deinit(db_res.database);
return 0;
}