Skip to content

Commit 02768e0

Browse files
authored
Merge pull request #40 from ryanfowler/agents
Add an AGENTS.md file
2 parents feafded + 32fe2a8 commit 02768e0

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/.claude
2+
/CLAUDE.md
3+
14
/target
25
/Cargo.lock
36

AGENTS.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# async-sqlite
2+
3+
This file provides guidance to AI agents when working with code in this repository. Keep this file updated after making changes.
4+
5+
## Project Overview
6+
7+
async-sqlite is a Rust library providing an asynchronous, runtime-agnostic wrapper around SQLite via `rusqlite`. It works with any async runtime (tokio, async-std, etc.) by using background threads internally rather than depending on a specific runtime.
8+
9+
## Build Commands
10+
11+
```bash
12+
cargo build # Build the library
13+
cargo test # Run all tests
14+
cargo fmt --all -- --check # Check formatting
15+
cargo clippy -- -D warnings # Lint (CI treats all warnings as errors)
16+
```
17+
18+
To run a single test:
19+
```bash
20+
cargo test <test_name> # e.g., cargo test test_blocking_client
21+
```
22+
23+
The minimum supported Rust version is 1.92.0.
24+
25+
## Architecture
26+
27+
The library has three core types in `src/`:
28+
29+
- **Client** (`client.rs`): Wraps a single SQLite connection. Spawns a background `std::thread` that receives commands (closures) via a `crossbeam_channel`. Results are returned through `futures_channel::oneshot`. This design makes it runtime-agnostic. Client is cheaply cloneable.
30+
31+
- **Pool** (`pool.rs`): Manages multiple `Client` instances with round-robin selection via an atomic counter. Provides the same API as Client plus `conn_for_each()` for executing on all connections. Defaults to CPU-count connections.
32+
33+
- **Error** (`error.rs`): Non-exhaustive enum wrapping `rusqlite::Error`, channel errors, and pragma failures.
34+
35+
All database operations use a closure-based API (e.g., `conn(|conn| { ... })`) to avoid lifetime issues with the cross-thread boundary. Both blocking and async variants exist for all operations.
36+
37+
## Features
38+
39+
All Cargo features are pass-through to `rusqlite`. The `bundled` feature (default) bundles SQLite. The library re-exports `rusqlite` for downstream use.
40+
41+
## Testing
42+
43+
Tests in `tests/tests.rs` use a `async_test!` macro that generates two variants of each async test: one running on tokio and one on async-std. This ensures runtime compatibility. Tests use `tempfile` for temporary database files.

0 commit comments

Comments
 (0)